examples/xenomai/main.c
author Florian Pose <fp@igh-essen.com>
Mon, 09 Jul 2012 10:29:15 +0200
changeset 2392 cc98844cc65c
parent 2056 a92e8f119723
child 2589 2b9c78543663
permissions -rw-r--r--
Removed whitespace.
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     2
 *
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     4
 *
2056
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2055
diff changeset
     5
 *  main.c	        Copyright (C) 2009-2010  Moehwald GmbH B.Benner
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     6
 *                                2011       IgH Andreas Stewering-Bone
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     7
 *
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     8
 *  This file is part of ethercatrtdm interface to IgH EtherCAT master 
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     9
 *  
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    10
 *  The Moehwald ethercatrtdm interface is free software; you can
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    11
 *  redistribute it and/or modify it under the terms of the GNU Lesser General
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    12
 *  Public License as published by the Free Software Foundation; version 2.1
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    13
 *  of the License.
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    14
 *
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    15
 *  The IgH EtherCAT Master is free software; you can redistribute it and/or
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    16
 *  modify it under the terms of the GNU General Public License version 2, as
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    17
 *  published by the Free Software Foundation.
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    18
 *
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    19
 *  The IgH EtherCAT master userspace library is distributed in the hope that
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    20
 *  it will be useful, but WITHOUT ANY WARRANTY; without even the implied
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    21
 *  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    22
 *  GNU Lesser General Public License for more details.
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    23
 *
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    24
 *  You should have received a copy of the GNU Lesser General Public License
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    25
 *  along with the IgH EtherCAT master userspace library. If not, see
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    26
 *  <http://www.gnu.org/licenses/>.
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    27
 *  
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    28
 *  The license mentioned above concerns the source code only. Using the
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    29
 *  EtherCAT technology and brand is only permitted in compliance with the
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    30
 *  industrial property and similar rights of Beckhoff Automation GmbH.
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    31
 *
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    32
 *****************************************************************************/
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    33
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    34
#include <errno.h>
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    35
#include <signal.h>
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    36
#include <stdio.h>
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    37
#include <string.h>
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    38
#include <sys/resource.h>
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    39
#include <sys/time.h>
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    40
#include <sys/types.h>
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    41
#include <unistd.h>
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    42
#include <sys/mman.h>
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    43
#include <rtdm/rtdm.h>
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    44
#include <native/task.h>
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    45
#include <native/sem.h>
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    46
#include <native/mutex.h>
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    47
#include <native/timer.h>
2055
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
    48
#include <rtdk.h>
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    49
#include <pthread.h>
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    50
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    51
/****************************************************************************/
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    52
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    53
#include "../../include/ecrt.h"
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    54
#include "../../include/ec_rtdm.h"
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    55
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    56
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    57
RT_TASK my_task;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    58
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    59
int rt_fd = -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    60
int run=0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    61
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    62
unsigned int sync_ref_counter = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    63
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    64
CstructMstrAttach MstrAttach;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    65
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    66
/****************************************************************************/
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    67
2056
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2055
diff changeset
    68
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    69
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    70
// Optional features
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    71
#define CONFIGURE_PDOS  1
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    72
//#define SDO_ACCESS      1
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    73
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    74
/****************************************************************************/
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    75
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    76
// EtherCAT
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    77
static ec_master_t *master = NULL;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    78
static ec_master_state_t master_state = {};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    79
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    80
static ec_domain_t *domain1 = NULL;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    81
static ec_domain_state_t domain1_state = {};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    82
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    83
//static ec_slave_config_t *sc_ana_in = NULL;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    84
//static ec_slave_config_state_t sc_ana_in_state = {};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    85
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    86
// Timer
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    87
static unsigned int sig_alarms = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    88
//static unsigned int user_alarms = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    89
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    90
/****************************************************************************/
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    91
static uint8_t *domain1_pd = NULL;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    92
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    93
// process data
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    94
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    95
#define BusCoupler01_Pos    0, 0
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    96
#define DigOutSlave01_Pos   0, 1
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    97
#define DigOutSlave02_Pos   0, 2
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    98
#define DigInSlave01_Pos    0, 3
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    99
#define AnaOutSlave01_Pos   0, 4
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   100
#define AnaInSlave01_Pos    0, 5
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   101
#define BusCoupler02_Pos    0, 6
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   102
#define AnaInSlave02_Pos    0, 7
2055
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   103
#define DPSlave01_Pos       0, 8
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   104
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   105
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   106
#define Beckhoff_EK1100 0x00000002, 0x044c2c52
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   107
#define Beckhoff_EL1014 0x00000002, 0x03f63052
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   108
#define Beckhoff_EL2004 0x00000002, 0x07d43052
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   109
#define Beckhoff_EL4132 0x00000002, 0x10243052
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   110
#define Beckhoff_EL3102 0x00000002, 0x0c1e3052
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   111
#define Beckhoff_EL4102 0x00000002, 0x10063052
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   112
#define Beckhoff_EL6731 0x00000002, 0x1a4b3052
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   113
#define Beckhoff_EL6600 0x00000002, 0x19c93052
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   114
#define Beckhoff_EL3602 0x00000002, 0x0e123052
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   115
#define Beckhoff_EL5151 0x00000002, 0x141f3052
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   116
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   117
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   118
// offsets for PDO entries
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   119
static unsigned int off_dig_out0      = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   120
static unsigned int off_dig_out1      = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   121
static unsigned int off_dig_out2      = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   122
static unsigned int off_dig_out3      = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   123
static unsigned int off_dig_out4      = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   124
static unsigned int off_dig_out5      = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   125
static unsigned int off_dig_out6      = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   126
static unsigned int off_dig_out7      = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   127
static unsigned int off_dig_in0       = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   128
static unsigned int off_dig_in1       = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   129
static unsigned int off_dig_in2       = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   130
static unsigned int off_dig_in3       = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   131
static unsigned int off_ana_out0      = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   132
static unsigned int off_ana_out1      = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   133
static unsigned int off_ana_in0_status = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   134
static unsigned int off_ana_in0_value  = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   135
static unsigned int off_ana_in1_status = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   136
static unsigned int off_ana_in1_value  = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   137
static unsigned int off_ana_in2_status = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   138
static unsigned int off_ana_in2_value  = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   139
static unsigned int off_ana_in3_status = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   140
static unsigned int off_ana_in3_value  = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   141
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   142
//static unsigned int off_dp_slave;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   143
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   144
// process data
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   145
unsigned int bit_position0=0; /* Pointer to a variable to store a bit */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   146
unsigned int bit_position1=0; /* Pointer to a variable to store a bit */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   147
unsigned int bit_position2=0; /* Pointer to a variable to store a bit */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   148
unsigned int bit_position3=0; /* Pointer to a variable to store a bit */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   149
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   150
const static ec_pdo_entry_reg_t domain1_regs[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   151
   {DigOutSlave01_Pos, Beckhoff_EL2004, 0x7000, 0x01, &off_dig_out0, &bit_position0},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   152
   {DigOutSlave01_Pos, Beckhoff_EL2004, 0x7010, 0x01, &off_dig_out1, &bit_position1},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   153
   {DigOutSlave01_Pos, Beckhoff_EL2004, 0x7020, 0x01, &off_dig_out2, &bit_position2},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   154
   {DigOutSlave01_Pos, Beckhoff_EL2004, 0x7030, 0x01, &off_dig_out3, &bit_position3},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   155
   {DigInSlave01_Pos,  Beckhoff_EL1014, 0x6000, 0x01, &off_dig_in0},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   156
   {AnaOutSlave01_Pos, Beckhoff_EL4132, 0x3001, 0x01, &off_ana_out0},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   157
   {AnaOutSlave01_Pos, Beckhoff_EL4132, 0x3002, 0x01, &off_ana_out1},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   158
   {AnaInSlave01_Pos,  Beckhoff_EL3102, 0x3101, 0x01, &off_ana_in0_status},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   159
   {AnaInSlave01_Pos,  Beckhoff_EL3102, 0x3101, 0x02, &off_ana_in0_value},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   160
   {AnaInSlave01_Pos,  Beckhoff_EL3102, 0x3102, 0x01, &off_ana_in1_status},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   161
   {AnaInSlave01_Pos,  Beckhoff_EL3102, 0x3102, 0x02, &off_ana_in1_value},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   162
   {}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   163
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   164
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   165
char rt_dev_file[64];
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   166
static unsigned int counter = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   167
static unsigned int blink = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   168
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   169
static ec_slave_config_t *sc_dig_out_01 = NULL;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   170
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   171
static ec_slave_config_t *sc_dig_out_02 = NULL;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   172
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   173
static ec_slave_config_t *sc_dig_in_01 = NULL;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   174
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   175
static ec_slave_config_t *sc_ana_out_01 = NULL;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   176
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   177
static ec_slave_config_t *sc_ana_in_01 = NULL;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   178
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   179
static ec_slave_config_t *sc_dpslv_01 = NULL;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   180
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   181
static ec_slave_config_t *sc_ana_in_02 = NULL;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   182
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   183
/*****************************************************************************/
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   184
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   185
/* Slave 1, "EL2004"
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   186
 * Vendor ID:       0x00000002
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   187
 * Product code:    0x07d43052
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   188
 * Revision number: 0x00100000
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   189
 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   190
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   191
ec_pdo_entry_info_t slave_1_pdo_entries[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   192
   {0x7000, 0x01, 1}, /* Output */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   193
   {0x7010, 0x01, 1}, /* Output */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   194
   {0x7020, 0x01, 1}, /* Output */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   195
   {0x7030, 0x01, 1}, /* Output */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   196
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   197
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   198
ec_pdo_info_t slave_1_pdos[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   199
   {0x1600, 1, slave_1_pdo_entries + 0}, /* Channel 1 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   200
   {0x1601, 1, slave_1_pdo_entries + 1}, /* Channel 2 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   201
   {0x1602, 1, slave_1_pdo_entries + 2}, /* Channel 3 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   202
   {0x1603, 1, slave_1_pdo_entries + 3}, /* Channel 4 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   203
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   204
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   205
ec_sync_info_t slave_1_syncs[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   206
   {0, EC_DIR_OUTPUT, 4, slave_1_pdos + 0, EC_WD_ENABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   207
   {0xff}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   208
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   209
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   210
/* Slave 2, "EL2004"
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   211
 * Vendor ID:       0x00000002
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   212
 * Product code:    0x07d43052
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   213
 * Revision number: 0x00100000
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   214
 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   215
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   216
ec_pdo_entry_info_t slave_2_pdo_entries[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   217
   {0x7000, 0x01, 1}, /* Output */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   218
   {0x7010, 0x01, 1}, /* Output */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   219
   {0x7020, 0x01, 1}, /* Output */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   220
   {0x7030, 0x01, 1}, /* Output */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   221
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   222
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   223
ec_pdo_info_t slave_2_pdos[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   224
   {0x1600, 1, slave_2_pdo_entries + 0}, /* Channel 1 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   225
   {0x1601, 1, slave_2_pdo_entries + 1}, /* Channel 2 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   226
   {0x1602, 1, slave_2_pdo_entries + 2}, /* Channel 3 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   227
   {0x1603, 1, slave_2_pdo_entries + 3}, /* Channel 4 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   228
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   229
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   230
ec_sync_info_t slave_2_syncs[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   231
   {0, EC_DIR_OUTPUT, 4, slave_2_pdos + 0, EC_WD_ENABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   232
   {0xff}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   233
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   234
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   235
/* Slave 3, "EL1014"
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   236
 * Vendor ID:       0x00000002
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   237
 * Product code:    0x03f63052
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   238
 * Revision number: 0x00100000
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   239
 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   240
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   241
ec_pdo_entry_info_t slave_3_pdo_entries[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   242
   {0x6000, 0x01, 1}, /* Input */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   243
   {0x6010, 0x01, 1}, /* Input */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   244
   {0x6020, 0x01, 1}, /* Input */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   245
   {0x6030, 0x01, 1}, /* Input */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   246
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   247
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   248
ec_pdo_info_t slave_3_pdos[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   249
   {0x1a00, 1, slave_3_pdo_entries + 0}, /* Channel 1 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   250
   {0x1a01, 1, slave_3_pdo_entries + 1}, /* Channel 2 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   251
   {0x1a02, 1, slave_3_pdo_entries + 2}, /* Channel 3 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   252
   {0x1a03, 1, slave_3_pdo_entries + 3}, /* Channel 4 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   253
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   254
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   255
ec_sync_info_t slave_3_syncs[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   256
   {0, EC_DIR_INPUT, 4, slave_3_pdos + 0, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   257
   {0xff}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   258
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   259
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   260
/* Slave 4, "EL4132"
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   261
 * Vendor ID:       0x00000002
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   262
 * Product code:    0x10243052
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   263
 * Revision number: 0x03f90000
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   264
 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   265
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   266
ec_pdo_entry_info_t slave_4_pdo_entries[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   267
   {0x3001, 0x01, 16}, /* Output */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   268
   {0x3002, 0x01, 16}, /* Output */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   269
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   270
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   271
ec_pdo_info_t slave_4_pdos[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   272
   {0x1600, 1, slave_4_pdo_entries + 0}, /* RxPDO 01 mapping */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   273
   {0x1601, 1, slave_4_pdo_entries + 1}, /* RxPDO 02 mapping */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   274
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   275
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   276
ec_sync_info_t slave_4_syncs[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   277
   {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   278
   {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   279
   {2, EC_DIR_OUTPUT, 2, slave_4_pdos + 0, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   280
   {3, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   281
   {0xff}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   282
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   283
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   284
/* Slave 5, "EL3102"
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   285
 * Vendor ID:       0x00000002
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   286
 * Product code:    0x0c1e3052
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   287
 * Revision number: 0x00000000
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   288
 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   289
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   290
ec_pdo_entry_info_t slave_5_pdo_entries[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   291
   {0x3101, 0x01, 8}, /* Status */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   292
   {0x3101, 0x02, 16}, /* Value */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   293
   {0x3102, 0x01, 8}, /* Status */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   294
   {0x3102, 0x02, 16}, /* Value */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   295
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   296
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   297
ec_pdo_info_t slave_5_pdos[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   298
   {0x1a00, 2, slave_5_pdo_entries + 0}, /* TxPDO 001 mapping */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   299
   {0x1a01, 2, slave_5_pdo_entries + 2}, /* TxPDO 002 mapping */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   300
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   301
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   302
ec_sync_info_t slave_5_syncs[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   303
   {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   304
   {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   305
   {2, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   306
   {3, EC_DIR_INPUT, 2, slave_5_pdos + 0, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   307
   {0xff}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   308
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   309
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   310
/* Slave 6, "EL6731-0010"
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   311
 * Vendor ID:       0x00000002
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   312
 * Product code:    0x1a4b3052
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   313
 * Revision number: 0x0011000a
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   314
 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   315
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   316
ec_sync_info_t slave_6_syncs[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   317
   {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   318
   {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   319
   {2, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   320
   {3, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   321
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   322
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   323
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   324
/* Slave 7, "EL6601"
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   325
 * Vendor ID:       0x00000002
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   326
 * Product code:    0x19c93052
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   327
 * Revision number: 0x00110000
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   328
 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   329
/*
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   330
ec_sync_info_t slave_7_syncs[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   331
   {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   332
   {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   333
   {2, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   334
   {3, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   335
   {0xff}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   336
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   337
*/
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   338
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   339
/* Master 0, Slave 7, "EL3602"
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   340
 * Vendor ID:       0x00000002
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   341
 * Product code:    0x0e123052
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   342
 * Revision number: 0x00100000
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   343
 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   344
ec_pdo_entry_info_t slave_7_pdo_entries[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   345
   {0x6000, 0x01, 1}, /* Underrange */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   346
   {0x6000, 0x02, 1}, /* Overrange */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   347
   {0x6000, 0x03, 2}, /* Limit 1 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   348
   {0x6000, 0x05, 2}, /* Limit 2 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   349
   {0x6000, 0x07, 1}, /* Error */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   350
   {0x0000, 0x00, 7}, /* Gap */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   351
   {0x1800, 0x07, 1},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   352
   {0x1800, 0x09, 1},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   353
   {0x6000, 0x11, 32}, /* Value */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   354
   {0x6010, 0x01, 1}, /* Underrange */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   355
   {0x6010, 0x02, 1}, /* Overrange */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   356
   {0x6010, 0x03, 2}, /* Limit 1 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   357
   {0x6010, 0x05, 2}, /* Limit 2 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   358
   {0x6010, 0x07, 1}, /* Error */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   359
   {0x0000, 0x00, 7}, /* Gap */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   360
   {0x1801, 0x07, 1},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   361
   {0x1801, 0x09, 1},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   362
   {0x6010, 0x11, 32}, /* Value */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   363
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   364
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   365
ec_pdo_info_t slave_7_pdos[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   366
   {0x1a00, 9, slave_7_pdo_entries + 0}, /* AI TxPDO-Map Inputs Ch.1 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   367
   {0x1a01, 9, slave_7_pdo_entries + 9}, /* AI TxPDO-Map Inputs Ch.2 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   368
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   369
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   370
ec_sync_info_t slave_7_syncs[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   371
   {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   372
   {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   373
   {2, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   374
   {3, EC_DIR_INPUT, 2, slave_7_pdos + 0, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   375
   {0xff}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   376
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   377
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   378
/* Master 0, Slave 8, "EL5151"
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   379
 * Vendor ID:       0x00000002
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   380
 * Product code:    0x141f3052
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   381
 * Revision number: 0x00130000
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   382
 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   383
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   384
ec_pdo_entry_info_t slave_8_pdo_entries[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   385
   {0x6000, 0x01, 1},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   386
   {0x6000, 0x02, 1},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   387
   {0x6000, 0x03, 1},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   388
   {0x0000, 0x00, 4}, /* Gap */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   389
   {0x6000, 0x08, 1},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   390
   {0x6000, 0x09, 1},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   391
   {0x6000, 0x0a, 1},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   392
   {0x6000, 0x0b, 1},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   393
   {0x0000, 0x00, 1}, /* Gap */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   394
   {0x6000, 0x0d, 1},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   395
   {0x1c32, 0x20, 1},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   396
   {0x0000, 0x00, 1}, /* Gap */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   397
   {0x1800, 0x09, 1},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   398
   {0x6000, 0x11, 32},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   399
   {0x6000, 0x12, 32},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   400
   {0x6000, 0x14, 32},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   401
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   402
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   403
ec_pdo_info_t slave_8_pdos[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   404
   {0x0000, 0, NULL},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   405
   {0x1a00, 15, slave_8_pdo_entries + 0},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   406
   {0x1a02, 1, slave_8_pdo_entries + 15},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   407
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   408
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   409
ec_sync_info_t slave_8_syncs[] = {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   410
   {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   411
   {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   412
   {2, EC_DIR_OUTPUT, 1, slave_8_pdos + 0, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   413
   {3, EC_DIR_INPUT, 2, slave_8_pdos + 1, EC_WD_DISABLE},
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   414
   {0xff}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   415
};
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   416
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   417
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   418
/*****************************************************************************/
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   419
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   420
#if SDO_ACCESS
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   421
static ec_sdo_request_t *sdo;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   422
uint8_t *sdo_adr = NULL;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   423
#endif
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   424
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   425
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   426
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   427
void rt_check_domain_state(void)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   428
{
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   429
    ec_domain_state_t ds;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   430
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   431
    if (rt_fd>=0)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   432
      {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   433
          ecrt_rtdm_domain_state(rt_fd,&ds);  
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   434
      }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   435
2055
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   436
    if (ds.working_counter != domain1_state.working_counter)
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   437
     {
2055
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   438
        rt_printf("Domain1: WC %u.\n", ds.working_counter);
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   439
     }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   440
    if (ds.wc_state != domain1_state.wc_state)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   441
     {
2055
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   442
    	rt_printf("Domain1: State %u.\n", ds.wc_state);
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   443
     }
2055
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   444
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   445
    domain1_state = ds;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   446
}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   447
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   448
void rt_check_master_state(void)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   449
{
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   450
    ec_master_state_t ms;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   451
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   452
    if (rt_fd>=0)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   453
      {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   454
          ecrt_rtdm_master_state(rt_fd,&ms);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   455
      }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   456
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   457
    if (ms.slaves_responding != master_state.slaves_responding)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   458
    {
2055
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   459
        rt_printf("%u slave(s).\n", ms.slaves_responding);
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   460
    }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   461
    if (ms.al_states != master_state.al_states)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   462
    {
2055
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   463
        rt_printf("AL states: 0x%02X.\n", ms.al_states);
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   464
    }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   465
    if (ms.link_up != master_state.link_up)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   466
    {
2055
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   467
        rt_printf("Link is %s.\n", ms.link_up ? "up" : "down");
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   468
    }
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   469
    master_state = ms;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   470
}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   471
2055
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   472
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   473
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   474
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   475
void rt_sync()
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   476
{
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   477
  RTIME now;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   478
  now = rt_timer_read();
2055
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   479
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   480
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   481
  if (rt_fd>=0)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   482
  {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   483
      ecrt_rtdm_master_application_time(rt_fd, &now);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   484
  }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   485
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   486
  if (sync_ref_counter) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   487
     sync_ref_counter--;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   488
  } else {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   489
     sync_ref_counter = 9;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   490
     if (rt_fd>=0)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   491
     {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   492
         ecrt_rtdm_master_sync_reference_clock(rt_fd);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   493
     }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   494
  }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   495
  if (rt_fd>=0)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   496
  {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   497
      ecrt_rtdm_master_sync_slave_clocks(rt_fd) ;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   498
  }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   499
}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   500
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   501
/*****************************************************************************/
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   502
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   503
#if SDO_ACCESS
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   504
void read_sdo(void)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   505
{
2055
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   506
    switch (ecrt_sdo_request_state(sdo))
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   507
        {
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   508
        case EC_REQUEST_UNUSED: // request was not used yet
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   509
            ecrt_sdo_request_read(sdo); // trigger first read
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   510
            break;
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   511
        case EC_REQUEST_BUSY:
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   512
            fprintf(stderr, "Still busy...\n");
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   513
            break;
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   514
        case EC_REQUEST_SUCCESS:
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   515
            fprintf(stderr, "SDO value: 0x%04X\n",
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   516
                    EC_READ_U16(ecrt_sdo_request_data(sdo)));
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   517
            ecrt_sdo_request_read(sdo); // trigger next read
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   518
            break;
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   519
        case EC_REQUEST_ERROR:
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   520
            fprintf(stderr, "Failed to read SDO!\n");
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   521
            ecrt_sdo_request_read(sdo); // retry reading
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   522
            break;
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   523
        }
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   524
}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   525
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   526
void  PrintSDOState(void)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   527
{
2055
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   528
    switch (ecrt_sdo_request_state(sdo))
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   529
        {
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   530
        case EC_REQUEST_UNUSED: // request was not used yet
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   531
            fprintf(stderr, "SDO State: EC_REQUEST_UNUSED\n"); // trigger first read
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   532
            break;
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   533
        case EC_REQUEST_BUSY:
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   534
            fprintf(stderr, "SDO State: EC_REQUEST_BUSY\n");
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   535
            break;
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   536
        case EC_REQUEST_SUCCESS:
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   537
            fprintf(stderr, "SDO State: EC_REQUEST_SUCCESS\n");
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   538
            break;
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   539
        case EC_REQUEST_ERROR:
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   540
            fprintf(stderr, "SDO State: EC_REQUEST_ERROR\n");
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   541
            break;
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   542
        default:
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   543
            fprintf(stderr, "SDO State: undefined\n");
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   544
            break;
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   545
  }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   546
}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   547
#endif
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   548
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   549
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   550
static int cyccount=0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   551
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   552
/****************************************************************************/
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   553
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   554
void signal_handler(int signum) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   555
    switch (signum) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   556
        case SIGALRM:
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   557
            sig_alarms++;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   558
            break;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   559
    }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   560
}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   561
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   562
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   563
/**********************************************************/
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   564
/*            REAL TIME TASK                              */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   565
/**********************************************************/
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   566
void my_task_proc(void *arg)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   567
{
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   568
  int counter = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   569
  int divcounter = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   570
  int divider = 10;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   571
  int ret;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   572
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   573
  RTIME periodns;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   574
  float period;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   575
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   576
2056
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2055
diff changeset
   577
  period=1E-3; //1kHz
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   578
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   579
  
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   580
  periodns=(RTIME)(((double)period * 1E9) + 0.4999999);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   581
  rt_task_set_periodic(NULL, TM_NOW, periodns);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   582
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   583
  run=1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   584
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   585
  ret = rt_task_set_mode(0, T_PRIMARY, NULL);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   586
  if (ret) {
2055
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   587
      rt_printf("error while rt_task_set_mode, code %d\n",ret);
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   588
      return;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   589
  }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   590
  
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   591
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   592
  while (run) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   593
      rt_task_wait_period(NULL);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   594
      
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   595
      counter++;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   596
      if (counter>600000) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   597
          run=0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   598
          return;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   599
      }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   600
      
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   601
      // receive ethercat
2055
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   602
      ecrt_rtdm_master_recieve(rt_fd);
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   603
      ecrt_rtdm_domain_process(rt_fd);
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   604
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   605
      rt_check_domain_state();
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   606
      
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   607
      if (divcounter ==0)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   608
          {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   609
              divcounter=divider;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   610
              rt_check_master_state();
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   611
          }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   612
      divcounter--;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   613
      if ((counter % 200)==0)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   614
          {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   615
              blink = !blink;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   616
              
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   617
          }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   618
      
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   619
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   620
      EC_WRITE_U8(domain1_pd + off_dig_out0, blink ? 0x0 : 0x0F);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   621
      EC_WRITE_U16(domain1_pd + off_ana_out0, blink ? 0x0: 0xfff);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   622
      
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   623
      //sync DC
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   624
      rt_sync();
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   625
      
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   626
      // send process data
2055
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   627
      ecrt_rtdm_domain_queque(rt_fd);
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   628
      ecrt_rtdm_master_send(rt_fd);
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   629
  }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   630
  
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   631
}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   632
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   633
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   634
/**********************************************************/
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   635
/*            CLEANING UP                                 */
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   636
/**********************************************************/
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   637
void cleanup_all(void)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   638
{
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   639
    printf("delete my_task\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   640
    rt_task_delete(&my_task);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   641
    
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   642
    if (rt_fd >= 0) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   643
        printf("closing rt device %s\n", &rt_dev_file[0]);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   644
        rt_dev_close(rt_fd);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   645
        
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   646
    }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   647
}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   648
/****************************************************************************/
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   649
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   650
void catch_signal(int sig) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   651
    cleanup_all();
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   652
    printf("exit\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   653
    exit(0);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   654
    return;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   655
}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   656
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   657
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   658
/****************************************************************************/
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   659
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   660
int main(int argc, char **argv)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   661
{
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   662
    ec_slave_config_t *sc;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   663
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   664
    int rtstatus;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   665
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   666
    mlockall(MCL_CURRENT | MCL_FUTURE);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   667
2055
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   668
    /* Perform auto-init of rt_print buffers if the task doesn't do so */
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   669
    rt_print_auto_init(1);
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   670
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   671
    signal(SIGTERM, catch_signal);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   672
    signal(SIGINT, catch_signal);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   673
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   674
    MstrAttach.masterindex = 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   675
    
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   676
    printf("request master\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   677
    master = ecrt_request_master(MstrAttach.masterindex);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   678
    if (!master)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   679
        return -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   680
    
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   681
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   682
    domain1 = ecrt_master_create_domain(master);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   683
    if (!domain1)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   684
        return -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   685
    
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   686
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   687
#ifdef CONFIGURE_PDOS
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   688
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   689
    printf("Configuring PDOs...\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   690
    
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   691
    printf("Get Configuring el2004...\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   692
    sc_dig_out_01 = ecrt_master_slave_config(master, DigOutSlave01_Pos, Beckhoff_EL2004);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   693
    if (!sc_dig_out_01) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   694
        fprintf(stderr, "Failed to get slave configuration.\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   695
        return -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   696
    }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   697
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   698
    printf("Configuring EL2004...\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   699
    if (ecrt_slave_config_pdos(sc_dig_out_01, EC_END, slave_1_syncs))
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   700
        {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   701
            fprintf(stderr, "Failed to configure PDOs.\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   702
            return -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   703
        }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   704
    
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   705
    printf("Get Configuring el2004...\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   706
    sc_dig_out_02 = ecrt_master_slave_config(master, DigOutSlave02_Pos, Beckhoff_EL2004);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   707
    if (!sc_dig_out_02) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   708
        fprintf(stderr, "Failed to get slave configuration.\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   709
        return -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   710
    }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   711
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   712
    printf("Configuring EL2004...\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   713
    if (ecrt_slave_config_pdos(sc_dig_out_02, EC_END, slave_2_syncs)) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   714
        fprintf(stderr, "Failed to configure PDOs.\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   715
        return -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   716
    }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   717
    
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   718
    printf("Get Configuring el1014...\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   719
    sc_dig_in_01 = ecrt_master_slave_config(master, DigInSlave01_Pos, Beckhoff_EL1014);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   720
    if (!sc_dig_in_01) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   721
        fprintf(stderr, "Failed to get slave configuration.\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   722
        return -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   723
    }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   724
    
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   725
    printf("Configuring EL1014...\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   726
    if (ecrt_slave_config_pdos(sc_dig_in_01, EC_END, slave_3_syncs)) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   727
        fprintf(stderr, "Failed to configure PDOs.\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   728
        return -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   729
    }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   730
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   731
    printf("Get Configuring EL4132...\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   732
    sc_ana_out_01 = ecrt_master_slave_config(master, AnaOutSlave01_Pos, Beckhoff_EL4132);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   733
    if (!sc_ana_out_01) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   734
        fprintf(stderr, "Failed to get slave configuration.\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   735
        return -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   736
    }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   737
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   738
    printf("Configuring EL4132...\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   739
    if (ecrt_slave_config_pdos(sc_ana_out_01, EC_END, slave_4_syncs)) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   740
        fprintf(stderr, "Failed to configure PDOs.\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   741
        return -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   742
    }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   743
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   744
    printf("Get Configuring EL3102...\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   745
    sc_ana_in_01 = ecrt_master_slave_config(master, AnaInSlave01_Pos, Beckhoff_EL3102);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   746
    if (!sc_ana_in_01) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   747
        fprintf(stderr, "Failed to get slave configuration.\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   748
        return -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   749
    }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   750
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   751
    printf("Configuring EL3102...\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   752
    if (ecrt_slave_config_pdos(sc_ana_in_01, EC_END, slave_5_syncs)) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   753
        fprintf(stderr, "Failed to configure PDOs.\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   754
        return -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   755
    }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   756
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   757
    printf("Get Configuring EL3602...\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   758
	sc_ana_in_02 = ecrt_master_slave_config(master, AnaInSlave02_Pos, Beckhoff_EL3602);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   759
	if (!sc_ana_in_02) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   760
        fprintf(stderr, "Failed to get slave configuration.\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   761
        return -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   762
	}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   763
    
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   764
	// DP Slave Parameter Set
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   765
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   766
/*	printf( "Creating SDO requests...\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   767
	if (!(sdo = ecrt_slave_config_create_sdo_request(sc_ana_in_02, 0x8000, 0x06, 1))) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   768
        fprintf(stderr, "Failed to create SDO request.\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   769
        return -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   770
	}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   771
	ecrt_sdo_request_timeout(sdo, 500); // ms
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   772
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   773
	EC_WRITE_U8(ecrt_sdo_request_data(sdo), 00);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   774
	PrintSDOState();
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   775
	ecrt_sdo_request_write(sdo);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   776
	PrintSDOState();
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   777
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   778
*/    
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   779
	printf("Configuring EL3602...\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   780
	if (ecrt_slave_config_pdos(sc_ana_in_02, EC_END, slave_7_syncs)) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   781
        fprintf(stderr, "Failed to configure PDOs.\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   782
        return -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   783
	}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   784
    
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   785
#endif
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   786
    
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   787
    // Create configuration for bus coupler
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   788
    sc = ecrt_master_slave_config(master, BusCoupler01_Pos, Beckhoff_EK1100);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   789
    if (!sc)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   790
        return -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   791
    
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   792
#ifdef CONFIGURE_PDOS
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   793
    if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   794
        fprintf(stderr, "PDO entry registration failed!\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   795
        return -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   796
    }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   797
#endif
2055
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   798
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   799
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   800
    printf("Get Configuring EL6731...\n");
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   801
    sc_dpslv_01 = ecrt_master_slave_config(master, DPSlave01_Pos, Beckhoff_EL6731);
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   802
    if (!sc_dpslv_01) {
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   803
        fprintf(stderr, "Failed to get slave configuration.\n");
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   804
        return -1;
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   805
    }
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   806
    
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   807
    printf("Configuring EL6731...\n");
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   808
    if (ecrt_slave_config_pdos(sc_dpslv_01, EC_END, slave_7_syncs))
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   809
        {
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   810
            fprintf(stderr, "Failed to configure PDOs.\n");
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   811
            return -1;
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   812
        }
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   813
    
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   814
#if SDO_ACCESS
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   815
    
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   816
    
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   817
    // DP Slave Parameter Set
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   818
    fprintf(stderr, "Creating SDO requests...\n");
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   819
    if (!(sdo = ecrt_slave_config_create_sdo_request(sc_dpslv_01, 0x8000, 0, 1))) {
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   820
        fprintf(stderr, "Failed to create SDO request.\n");
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   821
        return -1;
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   822
    }
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   823
    ecrt_sdo_request_timeout(sdo, 500); // ms
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   824
    EC_WRITE_U8(ecrt_sdo_request_data(sdo), 0);
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   825
    PrintSDOState();
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   826
    ecrt_sdo_request_write(sdo);
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   827
    PrintSDOState();
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   828
    
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   829
    // Station Address
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   830
    if (!(sdo = ecrt_slave_config_create_sdo_request(sc_dpslv_01, 0x8000, 1, 2))) {
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   831
        fprintf(stderr, "Failed to create SDO request.\n");
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   832
        return -1;
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   833
    }
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   834
    ecrt_sdo_request_timeout(sdo, 500); // ms
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   835
    EC_WRITE_U16(ecrt_sdo_request_data(sdo), 5);
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   836
    //EC_WRITE_U8(ecrt_sdo_request_data(sdo), 00);
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   837
    //EC_WRITE_U8(ecrt_sdo_request_data(sdo)+1, 10);
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   838
    PrintSDOState();
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   839
    ecrt_sdo_request_write(sdo);
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   840
    PrintSDOState();
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   841
    
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   842
    // Device Type (DP Ident Number)
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   843
    if (!(sdo = ecrt_slave_config_create_sdo_request(sc_dpslv_01, 0x8000, 4, 4))) {
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   844
        fprintf(stderr, "Failed to create SDO request.\n");
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   845
        return -1;
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   846
    }
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   847
    ecrt_sdo_request_timeout(sdo, 500); // ms
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   848
    sdo_adr = ecrt_sdo_request_data(sdo);
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   849
    EC_WRITE_U32(sdo_adr, 0x095F);
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   850
    //EC_WRITE_U8(sdo_ad, 0x00); // Device Type
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   851
    //EC_WRITE_U8(sdo_adr+1, 0x00);
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   852
    //EC_WRITE_U8(sdo_adr+2, 0x09);
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   853
    //EC_WRITE_U8(sdo_adr+3, 0x5F);
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   854
    PrintSDOState();
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   855
    ecrt_sdo_request_write(sdo);
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   856
    PrintSDOState();
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   857
    
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   858
    // DP CfgData Slave
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   859
    if (!(sdo = ecrt_slave_config_create_sdo_request(sc_dpslv_01, 0x8002, 0, 244))) {
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   860
        fprintf(stderr, "Failed to create SDO request.\n");
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   861
        return -1;
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   862
    }
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   863
    ecrt_sdo_request_timeout(sdo, 500); // ms
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   864
    sdo_adr = ecrt_sdo_request_data(sdo);
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   865
    EC_WRITE_U8(sdo_adr, 0x10); // Device Type
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   866
    EC_WRITE_U8(sdo_adr+1, 0x20);
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   867
    PrintSDOState();
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   868
    ecrt_sdo_request_write(sdo);
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   869
    PrintSDOState();
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   870
    
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   871
    // DP Slave Parameter Set
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   872
    if (!(sdo = ecrt_slave_config_create_sdo_request(sc_dpslv_01, 0x8000, 0, 1))) {
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   873
        fprintf(stderr, "Failed to create SDO request.\n");
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   874
        return -1;
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   875
    }
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   876
    
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   877
    ecrt_sdo_request_timeout(sdo, 500); // ms
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   878
    
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   879
    EC_WRITE_U8(ecrt_sdo_request_data(sdo), 0x33); // DP Slave Parameter Set
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   880
    PrintSDOState();
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   881
    ecrt_sdo_request_write(sdo);
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   882
    PrintSDOState();
d246ab6b50d2 Fix application time for RTDM interface
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2054
diff changeset
   883
#endif
2054
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   884
    
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   885
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   886
    
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   887
    sprintf(&rt_dev_file[0],"%s%u",EC_RTDM_DEV_FILE_NAME,0);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   888
    
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   889
    
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   890
    rt_fd = rt_dev_open( &rt_dev_file[0], 0);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   891
    if (rt_fd < 0) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   892
        printf("can't open %s\n", &rt_dev_file[0]);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   893
        return -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   894
    }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   895
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   896
    MstrAttach.domainindex = ecrt_domain_index(domain1);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   897
    
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   898
    // attach the master over rtdm driver
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   899
    rtstatus=ecrt_rtdm_master_attach(rt_fd, &MstrAttach);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   900
    if (rtstatus < 0)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   901
      {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   902
        printf("cannot attach to master over rtdm\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   903
        return -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   904
      }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   905
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   906
    printf("Activating master...\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   907
    if (ecrt_master_activate(master))
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   908
        return -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   909
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   910
    if (!(domain1_pd = ecrt_domain_data(domain1))) {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   911
        return -1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   912
    }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   913
    fprintf(stderr, "domain1_pd:  0x%.6x\n", (unsigned int)domain1_pd);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   914
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   915
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   916
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   917
    int ret;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   918
    run=1;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   919
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   920
    ret = rt_task_create(&my_task,"my_task",0,80,T_FPU);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   921
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   922
    printf("starting my_task\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   923
    ret = rt_task_start(&my_task,&my_task_proc,NULL);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   924
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   925
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   926
    while (run)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   927
      {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   928
    	sched_yield();
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   929
      }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   930
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   931
    rt_task_delete(&my_task);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   932
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   933
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   934
    if (rt_fd >= 0)
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   935
     {
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   936
        printf("closing rt device %s\n", &rt_dev_file[0]);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   937
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   938
        rt_dev_close(rt_fd);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   939
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   940
     }
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   941
 
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   942
    printf("End of Program\n");
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   943
    ecrt_release_master(master);
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   944
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   945
    return 0;
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   946
}
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   947
3417bbc4ad2f First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   948
/****************************************************************************/