examples/rtai_rtdm/main.c
author Florian Pose <fp@igh-essen.com>
Tue, 10 Jan 2012 11:58:09 +0100
changeset 2262 797756190ddb
parent 2059 ab0b96ac18bb
child 2589 2b9c78543663
permissions -rw-r--r--
Renamed original parts of e1000 driver for 2.6.29.
2058
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     2
 *
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     4
 *
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     5
 *  main.c	        Copyright (C) 2011       IgH Andreas Stewering-Bone
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     6
 *
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     7
 *  This file is part of ethercatrtdm interface to IgH EtherCAT master 
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     8
 *  
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     9
 *  The IgH EtherCAT master is free software; you can
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    10
 *  redistribute it and/or modify it under the terms of the GNU Lesser General
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    11
 *  Public License as published by the Free Software Foundation; version 2.1
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    12
 *  of the License.
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    13
 *
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    14
 *  The IgH EtherCAT Master is free software; you can redistribute it and/or
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    15
 *  modify it under the terms of the GNU General Public License version 2, as
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    16
 *  published by the Free Software Foundation.
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    17
 *
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    18
 *  The IgH EtherCAT master userspace library is distributed in the hope that
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    19
 *  it will be useful, but WITHOUT ANY WARRANTY; without even the implied
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    20
 *  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    21
 *  GNU Lesser General Public License for more details.
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    22
 *
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    23
 *  You should have received a copy of the GNU Lesser General Public License
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    24
 *  along with the IgH EtherCAT master userspace library. If not, see
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    25
 *  <http://www.gnu.org/licenses/>.
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    26
 *  
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    27
 *  The license mentioned above concerns the source code only. Using the
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    28
 *  EtherCAT technology and brand is only permitted in compliance with the
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    29
 *  industrial property and similar rights of Beckhoff Automation GmbH.
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    30
 *
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    31
 *****************************************************************************/
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    32
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    33
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    34
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    35
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    36
#include <sched.h>
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    37
#include <stdio.h>
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    38
#include <stdlib.h>
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    39
#include <fcntl.h>
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    40
#include <signal.h>
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    41
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    42
#include <rtai_lxrt.h>
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    43
#include <rtdm/rtdm.h>
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    44
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    45
#include "../../include/ecrt.h"
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    46
#include "../../include/ec_rtdm.h"
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    47
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    48
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    49
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    50
#define rt_printf(X,Y) 
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    51
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    52
#define NSEC_PER_SEC 1000000000
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    53
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    54
RT_TASK* task;    // Stores a handle.
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    55
int priority=0;   // Highest
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    56
int stack_size=0; // Use default (512)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    57
int msg_size=0;   // Use default (256)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    58
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    59
static unsigned int cycle = 1000; /* 1 ms */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    60
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    61
int rt_fd = -1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    62
int run=0;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    63
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    64
unsigned int sync_ref_counter = 0;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    65
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    66
CstructMstrAttach MstrAttach;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    67
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    68
/****************************************************************************/
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    69
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    70
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    71
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    72
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    73
// Optional features
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    74
#define CONFIGURE_PDOS  1
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    75
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    76
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    77
/****************************************************************************/
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    78
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    79
// EtherCAT
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    80
static ec_master_t *master = NULL;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    81
static ec_master_state_t master_state = {};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    82
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    83
static ec_domain_t *domain1 = NULL;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    84
static ec_domain_state_t domain1_state = {};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    85
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    86
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    87
/****************************************************************************/
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    88
static uint8_t *domain1_pd = NULL;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    89
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    90
// process data
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    91
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    92
#define BusCoupler01_Pos    0, 0
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    93
#define DigOutSlave01_Pos   0, 1
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    94
#define DigOutSlave02_Pos   0, 2
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    95
#define DigInSlave01_Pos    0, 3
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    96
#define AnaOutSlave01_Pos   0, 4
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    97
#define AnaInSlave01_Pos    0, 5
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    98
#define BusCoupler02_Pos    0, 6
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    99
#define AnaInSlave02_Pos    0, 7
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   100
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   101
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   102
#define Beckhoff_EK1100 0x00000002, 0x044c2c52
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   103
#define Beckhoff_EL1014 0x00000002, 0x03f63052
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   104
#define Beckhoff_EL2004 0x00000002, 0x07d43052
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   105
#define Beckhoff_EL4132 0x00000002, 0x10243052
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   106
#define Beckhoff_EL3102 0x00000002, 0x0c1e3052
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   107
#define Beckhoff_EL4102 0x00000002, 0x10063052
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   108
#define Beckhoff_EL6731 0x00000002, 0x1a4b3052
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   109
#define Beckhoff_EL6600 0x00000002, 0x19c93052
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   110
#define Beckhoff_EL3602 0x00000002, 0x0e123052
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   111
#define Beckhoff_EL5151 0x00000002, 0x141f3052
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   112
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   113
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   114
// offsets for PDO entries
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   115
static unsigned int off_dig_out0      = 0;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   116
static unsigned int off_dig_out1      = 0;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   117
static unsigned int off_dig_out2      = 0;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   118
static unsigned int off_dig_out3      = 0;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   119
static unsigned int off_dig_in0       = 0;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   120
static unsigned int off_ana_out0      = 0;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   121
static unsigned int off_ana_out1      = 0;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   122
static unsigned int off_ana_in0_status = 0;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   123
static unsigned int off_ana_in0_value  = 0;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   124
static unsigned int off_ana_in1_status = 0;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   125
static unsigned int off_ana_in1_value  = 0;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   126
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   127
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   128
// process data
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   129
unsigned int bit_position0=0; /* Pointer to a variable to store a bit */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   130
unsigned int bit_position1=0; /* Pointer to a variable to store a bit */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   131
unsigned int bit_position2=0; /* Pointer to a variable to store a bit */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   132
unsigned int bit_position3=0; /* Pointer to a variable to store a bit */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   133
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   134
const static ec_pdo_entry_reg_t domain1_regs[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   135
   {DigOutSlave01_Pos, Beckhoff_EL2004, 0x7000, 0x01, &off_dig_out0, &bit_position0},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   136
   {DigOutSlave01_Pos, Beckhoff_EL2004, 0x7010, 0x01, &off_dig_out1, &bit_position1},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   137
   {DigOutSlave01_Pos, Beckhoff_EL2004, 0x7020, 0x01, &off_dig_out2, &bit_position2},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   138
   {DigOutSlave01_Pos, Beckhoff_EL2004, 0x7030, 0x01, &off_dig_out3, &bit_position3},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   139
   {DigInSlave01_Pos,  Beckhoff_EL1014, 0x6000, 0x01, &off_dig_in0},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   140
   {AnaOutSlave01_Pos, Beckhoff_EL4132, 0x3001, 0x01, &off_ana_out0},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   141
   {AnaOutSlave01_Pos, Beckhoff_EL4132, 0x3002, 0x01, &off_ana_out1},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   142
   {AnaInSlave01_Pos,  Beckhoff_EL3102, 0x3101, 0x01, &off_ana_in0_status},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   143
   {AnaInSlave01_Pos,  Beckhoff_EL3102, 0x3101, 0x02, &off_ana_in0_value},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   144
   {AnaInSlave01_Pos,  Beckhoff_EL3102, 0x3102, 0x01, &off_ana_in1_status},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   145
   {AnaInSlave01_Pos,  Beckhoff_EL3102, 0x3102, 0x02, &off_ana_in1_value},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   146
   {}
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   147
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   148
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   149
char rt_dev_file[64];
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   150
static unsigned int blink = 0;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   151
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   152
static ec_slave_config_t *sc_dig_out_01 = NULL;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   153
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   154
static ec_slave_config_t *sc_dig_out_02 = NULL;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   155
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   156
static ec_slave_config_t *sc_dig_in_01 = NULL;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   157
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   158
static ec_slave_config_t *sc_ana_out_01 = NULL;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   159
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   160
static ec_slave_config_t *sc_ana_in_01 = NULL;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   161
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   162
static ec_slave_config_t *sc_ana_in_02 = NULL;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   163
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   164
/*****************************************************************************/
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   165
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   166
/* Slave 1, "EL2004"
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   167
 * Vendor ID:       0x00000002
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   168
 * Product code:    0x07d43052
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   169
 * Revision number: 0x00100000
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   170
 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   171
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   172
ec_pdo_entry_info_t slave_1_pdo_entries[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   173
   {0x7000, 0x01, 1}, /* Output */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   174
   {0x7010, 0x01, 1}, /* Output */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   175
   {0x7020, 0x01, 1}, /* Output */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   176
   {0x7030, 0x01, 1}, /* Output */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   177
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   178
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   179
ec_pdo_info_t slave_1_pdos[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   180
   {0x1600, 1, slave_1_pdo_entries + 0}, /* Channel 1 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   181
   {0x1601, 1, slave_1_pdo_entries + 1}, /* Channel 2 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   182
   {0x1602, 1, slave_1_pdo_entries + 2}, /* Channel 3 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   183
   {0x1603, 1, slave_1_pdo_entries + 3}, /* Channel 4 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   184
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   185
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   186
ec_sync_info_t slave_1_syncs[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   187
   {0, EC_DIR_OUTPUT, 4, slave_1_pdos + 0, EC_WD_ENABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   188
   {0xff}
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   189
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   190
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   191
/* Slave 2, "EL2004"
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   192
 * Vendor ID:       0x00000002
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   193
 * Product code:    0x07d43052
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   194
 * Revision number: 0x00100000
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   195
 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   196
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   197
ec_pdo_entry_info_t slave_2_pdo_entries[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   198
   {0x7000, 0x01, 1}, /* Output */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   199
   {0x7010, 0x01, 1}, /* Output */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   200
   {0x7020, 0x01, 1}, /* Output */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   201
   {0x7030, 0x01, 1}, /* Output */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   202
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   203
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   204
ec_pdo_info_t slave_2_pdos[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   205
   {0x1600, 1, slave_2_pdo_entries + 0}, /* Channel 1 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   206
   {0x1601, 1, slave_2_pdo_entries + 1}, /* Channel 2 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   207
   {0x1602, 1, slave_2_pdo_entries + 2}, /* Channel 3 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   208
   {0x1603, 1, slave_2_pdo_entries + 3}, /* Channel 4 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   209
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   210
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   211
ec_sync_info_t slave_2_syncs[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   212
   {0, EC_DIR_OUTPUT, 4, slave_2_pdos + 0, EC_WD_ENABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   213
   {0xff}
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   214
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   215
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   216
/* Slave 3, "EL1014"
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   217
 * Vendor ID:       0x00000002
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   218
 * Product code:    0x03f63052
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   219
 * Revision number: 0x00100000
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   220
 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   221
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   222
ec_pdo_entry_info_t slave_3_pdo_entries[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   223
   {0x6000, 0x01, 1}, /* Input */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   224
   {0x6010, 0x01, 1}, /* Input */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   225
   {0x6020, 0x01, 1}, /* Input */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   226
   {0x6030, 0x01, 1}, /* Input */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   227
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   228
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   229
ec_pdo_info_t slave_3_pdos[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   230
   {0x1a00, 1, slave_3_pdo_entries + 0}, /* Channel 1 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   231
   {0x1a01, 1, slave_3_pdo_entries + 1}, /* Channel 2 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   232
   {0x1a02, 1, slave_3_pdo_entries + 2}, /* Channel 3 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   233
   {0x1a03, 1, slave_3_pdo_entries + 3}, /* Channel 4 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   234
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   235
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   236
ec_sync_info_t slave_3_syncs[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   237
   {0, EC_DIR_INPUT, 4, slave_3_pdos + 0, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   238
   {0xff}
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   239
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   240
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   241
/* Slave 4, "EL4132"
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   242
 * Vendor ID:       0x00000002
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   243
 * Product code:    0x10243052
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   244
 * Revision number: 0x03f90000
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   245
 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   246
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   247
ec_pdo_entry_info_t slave_4_pdo_entries[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   248
   {0x3001, 0x01, 16}, /* Output */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   249
   {0x3002, 0x01, 16}, /* Output */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   250
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   251
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   252
ec_pdo_info_t slave_4_pdos[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   253
   {0x1600, 1, slave_4_pdo_entries + 0}, /* RxPDO 01 mapping */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   254
   {0x1601, 1, slave_4_pdo_entries + 1}, /* RxPDO 02 mapping */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   255
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   256
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   257
ec_sync_info_t slave_4_syncs[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   258
   {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   259
   {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   260
   {2, EC_DIR_OUTPUT, 2, slave_4_pdos + 0, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   261
   {3, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   262
   {0xff}
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   263
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   264
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   265
/* Slave 5, "EL3102"
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   266
 * Vendor ID:       0x00000002
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   267
 * Product code:    0x0c1e3052
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   268
 * Revision number: 0x00000000
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   269
 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   270
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   271
ec_pdo_entry_info_t slave_5_pdo_entries[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   272
   {0x3101, 0x01, 8}, /* Status */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   273
   {0x3101, 0x02, 16}, /* Value */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   274
   {0x3102, 0x01, 8}, /* Status */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   275
   {0x3102, 0x02, 16}, /* Value */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   276
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   277
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   278
ec_pdo_info_t slave_5_pdos[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   279
   {0x1a00, 2, slave_5_pdo_entries + 0}, /* TxPDO 001 mapping */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   280
   {0x1a01, 2, slave_5_pdo_entries + 2}, /* TxPDO 002 mapping */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   281
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   282
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   283
ec_sync_info_t slave_5_syncs[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   284
   {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   285
   {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   286
   {2, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   287
   {3, EC_DIR_INPUT, 2, slave_5_pdos + 0, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   288
   {0xff}
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   289
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   290
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   291
/* Slave 6, "EL6731-0010"
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   292
 * Vendor ID:       0x00000002
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   293
 * Product code:    0x1a4b3052
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   294
 * Revision number: 0x0011000a
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   295
 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   296
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   297
ec_sync_info_t slave_6_syncs[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   298
   {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   299
   {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   300
   {2, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   301
   {3, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   302
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   303
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   304
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   305
/* Slave 7, "EL6601"
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   306
 * Vendor ID:       0x00000002
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   307
 * Product code:    0x19c93052
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   308
 * Revision number: 0x00110000
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   309
 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   310
/*
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   311
ec_sync_info_t slave_7_syncs[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   312
   {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   313
   {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   314
   {2, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   315
   {3, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   316
   {0xff}
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   317
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   318
*/
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   319
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   320
/* Master 0, Slave 7, "EL3602"
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   321
 * Vendor ID:       0x00000002
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   322
 * Product code:    0x0e123052
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   323
 * Revision number: 0x00100000
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   324
 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   325
ec_pdo_entry_info_t slave_7_pdo_entries[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   326
   {0x6000, 0x01, 1}, /* Underrange */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   327
   {0x6000, 0x02, 1}, /* Overrange */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   328
   {0x6000, 0x03, 2}, /* Limit 1 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   329
   {0x6000, 0x05, 2}, /* Limit 2 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   330
   {0x6000, 0x07, 1}, /* Error */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   331
   {0x0000, 0x00, 7}, /* Gap */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   332
   {0x1800, 0x07, 1},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   333
   {0x1800, 0x09, 1},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   334
   {0x6000, 0x11, 32}, /* Value */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   335
   {0x6010, 0x01, 1}, /* Underrange */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   336
   {0x6010, 0x02, 1}, /* Overrange */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   337
   {0x6010, 0x03, 2}, /* Limit 1 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   338
   {0x6010, 0x05, 2}, /* Limit 2 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   339
   {0x6010, 0x07, 1}, /* Error */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   340
   {0x0000, 0x00, 7}, /* Gap */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   341
   {0x1801, 0x07, 1},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   342
   {0x1801, 0x09, 1},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   343
   {0x6010, 0x11, 32}, /* Value */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   344
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   345
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   346
ec_pdo_info_t slave_7_pdos[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   347
   {0x1a00, 9, slave_7_pdo_entries + 0}, /* AI TxPDO-Map Inputs Ch.1 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   348
   {0x1a01, 9, slave_7_pdo_entries + 9}, /* AI TxPDO-Map Inputs Ch.2 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   349
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   350
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   351
ec_sync_info_t slave_7_syncs[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   352
   {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   353
   {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   354
   {2, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   355
   {3, EC_DIR_INPUT, 2, slave_7_pdos + 0, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   356
   {0xff}
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   357
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   358
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   359
/* Master 0, Slave 8, "EL5151"
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   360
 * Vendor ID:       0x00000002
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   361
 * Product code:    0x141f3052
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   362
 * Revision number: 0x00130000
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   363
 */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   364
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   365
ec_pdo_entry_info_t slave_8_pdo_entries[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   366
   {0x6000, 0x01, 1},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   367
   {0x6000, 0x02, 1},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   368
   {0x6000, 0x03, 1},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   369
   {0x0000, 0x00, 4}, /* Gap */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   370
   {0x6000, 0x08, 1},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   371
   {0x6000, 0x09, 1},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   372
   {0x6000, 0x0a, 1},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   373
   {0x6000, 0x0b, 1},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   374
   {0x0000, 0x00, 1}, /* Gap */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   375
   {0x6000, 0x0d, 1},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   376
   {0x1c32, 0x20, 1},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   377
   {0x0000, 0x00, 1}, /* Gap */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   378
   {0x1800, 0x09, 1},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   379
   {0x6000, 0x11, 32},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   380
   {0x6000, 0x12, 32},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   381
   {0x6000, 0x14, 32},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   382
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   383
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   384
ec_pdo_info_t slave_8_pdos[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   385
   {0x0000, 0, NULL},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   386
   {0x1a00, 15, slave_8_pdo_entries + 0},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   387
   {0x1a02, 1, slave_8_pdo_entries + 15},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   388
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   389
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   390
ec_sync_info_t slave_8_syncs[] = {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   391
   {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   392
   {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   393
   {2, EC_DIR_OUTPUT, 1, slave_8_pdos + 0, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   394
   {3, EC_DIR_INPUT, 2, slave_8_pdos + 1, EC_WD_DISABLE},
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   395
   {0xff}
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   396
};
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   397
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   398
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   399
/*****************************************************************************/
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   400
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   401
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   402
void rt_check_domain_state(void)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   403
{
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   404
    ec_domain_state_t ds;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   405
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   406
    if (rt_fd>=0)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   407
      {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   408
          ecrt_rtdm_domain_state(rt_fd,&ds);  
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   409
      }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   410
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   411
    if (ds.working_counter != domain1_state.working_counter)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   412
     {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   413
        rt_printf("Domain1: WC %u.\n", ds.working_counter);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   414
     }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   415
    if (ds.wc_state != domain1_state.wc_state)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   416
     {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   417
    	rt_printf("Domain1: State %u.\n", ds.wc_state);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   418
     }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   419
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   420
    domain1_state = ds;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   421
}
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   422
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   423
void rt_check_master_state(void)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   424
{
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   425
    ec_master_state_t ms;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   426
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   427
    if (rt_fd>=0)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   428
      {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   429
          ecrt_rtdm_master_state(rt_fd,&ms);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   430
      }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   431
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   432
    if (ms.slaves_responding != master_state.slaves_responding)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   433
    {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   434
        rt_printf("%u slave(s).\n", ms.slaves_responding);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   435
    }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   436
    if (ms.al_states != master_state.al_states)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   437
    {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   438
        rt_printf("AL states: 0x%02X.\n", ms.al_states);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   439
    }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   440
    if (ms.link_up != master_state.link_up)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   441
    {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   442
        rt_printf("Link is %s.\n", ms.link_up ? "up" : "down");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   443
    }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   444
    master_state = ms;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   445
}
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   446
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   447
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   448
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   449
2059
ab0b96ac18bb Working RTAI LXRT example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2058
diff changeset
   450
void rt_sync(void)
2058
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   451
{
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   452
2059
ab0b96ac18bb Working RTAI LXRT example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2058
diff changeset
   453
  RTIME now_ns;
ab0b96ac18bb Working RTAI LXRT example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2058
diff changeset
   454
  uint64_t now;
ab0b96ac18bb Working RTAI LXRT example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2058
diff changeset
   455
  now_ns = rt_get_cpu_time_ns();
ab0b96ac18bb Working RTAI LXRT example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2058
diff changeset
   456
  now = (uint64_t)now_ns;
2058
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   457
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   458
  if (rt_fd>=0)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   459
  {
2059
ab0b96ac18bb Working RTAI LXRT example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2058
diff changeset
   460
      ecrt_rtdm_master_application_time(rt_fd, &now);
2058
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   461
  }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   462
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   463
  if (sync_ref_counter) {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   464
     sync_ref_counter--;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   465
  } else {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   466
     sync_ref_counter = 9;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   467
     if (rt_fd>=0)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   468
     {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   469
         ecrt_rtdm_master_sync_reference_clock(rt_fd);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   470
     }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   471
  }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   472
  if (rt_fd>=0)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   473
  {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   474
      ecrt_rtdm_master_sync_slave_clocks(rt_fd) ;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   475
  }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   476
}
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   477
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   478
/*****************************************************************************/
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   479
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   480
/**********************************************************/
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   481
void cleanup_all(void)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   482
{
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   483
    run = 0;   
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   484
}
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   485
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   486
void catch_signal(int sig)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   487
{
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   488
    cleanup_all();    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   489
}
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   490
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   491
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   492
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   493
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   494
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   495
void my_cyclic(void)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   496
{
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   497
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   498
    int counter = 0;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   499
    int divcounter = 0;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   500
    int divider = 10;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   501
    int period;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   502
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   503
    rt_set_periodic_mode();
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   504
    period = (int) nano2count((RTIME)cycle*1000);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   505
    start_rt_timer(period);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   506
    rt_make_hard_real_time();
2059
ab0b96ac18bb Working RTAI LXRT example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2058
diff changeset
   507
    rt_task_make_periodic(task, rt_get_time() + 10*period, period);
ab0b96ac18bb Working RTAI LXRT example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2058
diff changeset
   508
2058
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   509
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   510
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   511
    while(1) {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   512
 
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   513
        rt_task_wait_period();
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   514
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   515
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   516
        counter++;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   517
        if (counter>60000) {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   518
            run=0;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   519
        }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   520
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   521
        if(run ==  0) {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   522
            rt_make_soft_real_time();
2059
ab0b96ac18bb Working RTAI LXRT example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2058
diff changeset
   523
            stop_rt_timer();
2058
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   524
            return;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   525
        }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   526
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   527
        
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   528
        // receive ethercat
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   529
        ecrt_rtdm_master_recieve(rt_fd);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   530
        ecrt_rtdm_domain_process(rt_fd);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   531
        
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   532
        rt_check_domain_state();
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   533
        
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   534
        if (divcounter ==0)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   535
            {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   536
                divcounter=divider;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   537
                rt_check_master_state();
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   538
            }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   539
        divcounter--;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   540
        if ((counter % 200)==0)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   541
            {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   542
                blink = !blink;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   543
                
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   544
            }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   545
      
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   546
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   547
        EC_WRITE_U8(domain1_pd + off_dig_out0, blink ? 0x0 : 0x0F);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   548
        EC_WRITE_U16(domain1_pd + off_ana_out0, blink ? 0x0: 0xfff);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   549
        
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   550
        //sync DC
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   551
        rt_sync();
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   552
        
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   553
        // send process data
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   554
        ecrt_rtdm_domain_queque(rt_fd);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   555
        ecrt_rtdm_master_send(rt_fd);   
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   556
    }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   557
    return;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   558
}
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   559
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   560
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   561
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   562
int main(int argc, char *argv[])
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   563
{
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   564
    ec_slave_config_t *sc;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   565
    int rtstatus;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   566
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   567
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   568
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   569
    signal(SIGTERM, catch_signal);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   570
    signal(SIGINT, catch_signal);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   571
    signal(SIGHUP, catch_signal);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   572
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   573
    mlockall(MCL_CURRENT|MCL_FUTURE);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   574
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   575
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   576
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   577
    MstrAttach.masterindex = 0;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   578
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   579
    printf("request master\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   580
    master = ecrt_request_master(MstrAttach.masterindex);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   581
    if (!master)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   582
        return -1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   583
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   584
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   585
    domain1 = ecrt_master_create_domain(master);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   586
    if (!domain1)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   587
        return -1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   588
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   589
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   590
#ifdef CONFIGURE_PDOS
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   591
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   592
    printf("Configuring PDOs...\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   593
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   594
    printf("Get Configuring el2004...\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   595
    sc_dig_out_01 = ecrt_master_slave_config(master, DigOutSlave01_Pos, Beckhoff_EL2004);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   596
    if (!sc_dig_out_01) {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   597
        fprintf(stderr, "Failed to get slave configuration.\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   598
        return -1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   599
    }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   600
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   601
    printf("Configuring EL2004...\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   602
    if (ecrt_slave_config_pdos(sc_dig_out_01, EC_END, slave_1_syncs))
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   603
        {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   604
            fprintf(stderr, "Failed to configure PDOs.\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   605
            return -1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   606
        }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   607
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   608
    printf("Get Configuring el2004...\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   609
    sc_dig_out_02 = ecrt_master_slave_config(master, DigOutSlave02_Pos, Beckhoff_EL2004);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   610
    if (!sc_dig_out_02) {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   611
        fprintf(stderr, "Failed to get slave configuration.\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   612
        return -1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   613
    }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   614
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   615
    printf("Configuring EL2004...\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   616
    if (ecrt_slave_config_pdos(sc_dig_out_02, EC_END, slave_2_syncs)) {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   617
        fprintf(stderr, "Failed to configure PDOs.\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   618
        return -1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   619
    }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   620
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   621
    printf("Get Configuring el1014...\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   622
    sc_dig_in_01 = ecrt_master_slave_config(master, DigInSlave01_Pos, Beckhoff_EL1014);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   623
    if (!sc_dig_in_01) {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   624
        fprintf(stderr, "Failed to get slave configuration.\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   625
        return -1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   626
    }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   627
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   628
    printf("Configuring EL1014...\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   629
    if (ecrt_slave_config_pdos(sc_dig_in_01, EC_END, slave_3_syncs)) {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   630
        fprintf(stderr, "Failed to configure PDOs.\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   631
        return -1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   632
    }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   633
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   634
    printf("Get Configuring EL4132...\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   635
    sc_ana_out_01 = ecrt_master_slave_config(master, AnaOutSlave01_Pos, Beckhoff_EL4132);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   636
    if (!sc_ana_out_01) {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   637
        fprintf(stderr, "Failed to get slave configuration.\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   638
        return -1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   639
    }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   640
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   641
    printf("Configuring EL4132...\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   642
    if (ecrt_slave_config_pdos(sc_ana_out_01, EC_END, slave_4_syncs)) {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   643
        fprintf(stderr, "Failed to configure PDOs.\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   644
        return -1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   645
    }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   646
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   647
    printf("Get Configuring EL3102...\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   648
    sc_ana_in_01 = ecrt_master_slave_config(master, AnaInSlave01_Pos, Beckhoff_EL3102);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   649
    if (!sc_ana_in_01) {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   650
        fprintf(stderr, "Failed to get slave configuration.\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   651
        return -1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   652
    }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   653
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   654
    printf("Configuring EL3102...\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   655
    if (ecrt_slave_config_pdos(sc_ana_in_01, EC_END, slave_5_syncs)) {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   656
        fprintf(stderr, "Failed to configure PDOs.\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   657
        return -1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   658
    }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   659
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   660
    printf("Get Configuring EL3602...\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   661
	sc_ana_in_02 = ecrt_master_slave_config(master, AnaInSlave02_Pos, Beckhoff_EL3602);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   662
	if (!sc_ana_in_02) {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   663
        fprintf(stderr, "Failed to get slave configuration.\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   664
        return -1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   665
	}
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   666
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   667
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   668
	printf("Configuring EL3602...\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   669
	if (ecrt_slave_config_pdos(sc_ana_in_02, EC_END, slave_7_syncs)) {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   670
        fprintf(stderr, "Failed to configure PDOs.\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   671
        return -1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   672
	}
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   673
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   674
#endif
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   675
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   676
    // Create configuration for bus coupler
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   677
    sc = ecrt_master_slave_config(master, BusCoupler01_Pos, Beckhoff_EK1100);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   678
    if (!sc)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   679
        return -1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   680
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   681
#ifdef CONFIGURE_PDOS
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   682
    if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   683
        fprintf(stderr, "PDO entry registration failed!\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   684
        return -1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   685
    }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   686
#endif
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   687
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   688
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   689
        
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   690
    sprintf(&rt_dev_file[0],"%s%u",EC_RTDM_DEV_FILE_NAME,0);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   691
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   692
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   693
    rt_fd = rt_dev_open( &rt_dev_file[0], 0);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   694
    if (rt_fd < 0) {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   695
        printf("can't open %s\n", &rt_dev_file[0]);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   696
        return -1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   697
    }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   698
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   699
    MstrAttach.domainindex = ecrt_domain_index(domain1);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   700
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   701
    // attach the master over rtdm driver
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   702
    rtstatus=ecrt_rtdm_master_attach(rt_fd, &MstrAttach);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   703
    if (rtstatus < 0)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   704
        {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   705
            printf("cannot attach to master over rtdm\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   706
            return -1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   707
        }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   708
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   709
    printf("Activating master...\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   710
    if (ecrt_master_activate(master))
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   711
        return -1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   712
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   713
    if (!(domain1_pd = ecrt_domain_data(domain1))) {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   714
        return -1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   715
    }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   716
    fprintf(stderr, "domain1_pd:  0x%.6x\n", (unsigned int)domain1_pd);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   717
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   718
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   719
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   720
    run=1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   721
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   722
    /* Create cyclic RT-thread */
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   723
    struct sched_param param;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   724
    param.sched_priority = sched_get_priority_max(SCHED_FIFO) - 1;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   725
    if( sched_setscheduler( 0, SCHED_FIFO, &param ) == -1 ) {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   726
      puts("ERROR IN SETTING THE SCHEDULER");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   727
      perror("errno");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   728
      exit(1);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   729
    }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   730
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   731
    task = rt_task_init( nam2num("ec_rtai_rtdm_example"), priority, stack_size, msg_size);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   732
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   733
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   734
    my_cyclic();
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   735
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   736
    rt_task_delete(task);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   737
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   738
    if (rt_fd >= 0)
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   739
        {
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   740
            printf("closing rt device %s\n", &rt_dev_file[0]);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   741
            
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   742
            rt_dev_close(rt_fd);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   743
            
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   744
        }
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   745
    
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   746
    printf("End of Program\n");
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   747
    ecrt_release_master(master);
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   748
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   749
    return 0;
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   750
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   751
}
543c4ce9e86e Working RTAI RTDM module
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   752