master/fsm.h
author Florian Pose <fp@igh-essen.com>
Tue, 13 Feb 2007 13:36:31 +0000
branchstable-1.2
changeset 1738 bc89e3fba1a5
parent 1733 69f0fbc0dcab
permissions -rw-r--r--
Re-added sysconfig file.
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 *  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *  This file is part of the IgH EtherCAT Master.
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
 *  and/or modify it under the terms of the GNU General Public License
246
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    11
 *  as published by the Free Software Foundation; either version 2 of the
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    12
 *  License, or (at your option) any later version.
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
 *
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
 *  The IgH EtherCAT Master is distributed in the hope that it will be
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
 *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
 *  GNU General Public License for more details.
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
 *
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
 *  You should have received a copy of the GNU General Public License
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
 *  along with the IgH EtherCAT Master; if not, write to the Free Software
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
 *
246
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    23
 *  The right to use EtherCAT Technology is granted and comes free of
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    24
 *  charge under condition of compatibility of product made by
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    25
 *  Licensee. People intending to distribute/sell products based on the
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    26
 *  code, have to sign an agreement to guarantee that products using
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    27
 *  software based on IgH EtherCAT master stay compatible with the actual
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    28
 *  EtherCAT specification (which are released themselves as an open
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    29
 *  standard) as the (only) precondition to have the right to use EtherCAT
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    30
 *  Technology, IP and trade marks.
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    31
 *
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
 *****************************************************************************/
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
/**
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
   \file
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
   EtherCAT finite state machines.
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
*/
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
/*****************************************************************************/
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
#ifndef __EC_STATES__
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
#define __EC_STATES__
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 293
diff changeset
    44
#include "globals.h"
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
#include "../include/ecrt.h"
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 286
diff changeset
    46
#include "datagram.h"
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
#include "slave.h"
1732
1cc865ba17c2 MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents: 1719
diff changeset
    48
#include "canopen.h"
1cc865ba17c2 MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents: 1719
diff changeset
    49
1cc865ba17c2 MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents: 1719
diff changeset
    50
#include "fsm_sii.h"
1cc865ba17c2 MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents: 1719
diff changeset
    51
#include "fsm_change.h"
1cc865ba17c2 MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents: 1719
diff changeset
    52
#include "fsm_coe.h"
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
/*****************************************************************************/
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
286
f3352378b4d4 Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents: 269
diff changeset
    56
typedef struct ec_fsm ec_fsm_t; /**< \see ec_fsm */
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
/**
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
   Finite state machine of an EtherCAT master.
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
*/
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
struct ec_fsm
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
{
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
    ec_master_t *master; /**< master the FSM runs on */
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
    ec_slave_t *slave; /**< slave the FSM runs on */
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 286
diff changeset
    66
    ec_datagram_t datagram; /**< datagram used in the state machine */
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
    void (*master_state)(ec_fsm_t *); /**< master state function */
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
    unsigned int master_slaves_responding; /**< number of responding slaves */
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
    ec_slave_state_t master_slave_states; /**< states of responding slaves */
260
5fe7df7f2433 Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents: 251
diff changeset
    71
    unsigned int master_validation; /**< non-zero, if validation to do */
1732
1cc865ba17c2 MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents: 1719
diff changeset
    72
    uint16_t sii_offset; /**< current offset for SII access */
1cc865ba17c2 MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents: 1719
diff changeset
    73
    ec_sdo_request_t *sdo_request;
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
    void (*slave_state)(ec_fsm_t *); /**< slave state function */
1732
1cc865ba17c2 MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents: 1719
diff changeset
    76
    ec_sdo_data_t *sdodata; /**< SDO configuration data */
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
1732
1cc865ba17c2 MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents: 1719
diff changeset
    78
    ec_fsm_sii_t fsm_sii; /**< SII state machine */
1cc865ba17c2 MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents: 1719
diff changeset
    79
    ec_fsm_change_t fsm_change; /**< State change state machine */
1cc865ba17c2 MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents: 1719
diff changeset
    80
    ec_fsm_coe_t fsm_coe; /**< CoE state machine */
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
};
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
/*****************************************************************************/
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
int ec_fsm_init(ec_fsm_t *, ec_master_t *);
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
void ec_fsm_clear(ec_fsm_t *);
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
1732
1cc865ba17c2 MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents: 1719
diff changeset
    88
int ec_fsm_exec(ec_fsm_t *);
1cc865ba17c2 MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents: 1719
diff changeset
    89
int ec_fsm_running(ec_fsm_t *);
1cc865ba17c2 MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents: 1719
diff changeset
    90
int ec_fsm_success(ec_fsm_t *);
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 293
diff changeset
    91
1732
1cc865ba17c2 MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents: 1719
diff changeset
    92
// TODO: layout slave state machines
1733
69f0fbc0dcab MERGE trunk -r682:685 -> branches/stable-1.1 (Fixed dist files, source docs, version 1.1.1)
Florian Pose <fp@igh-essen.com>
parents: 1732
diff changeset
    93
69f0fbc0dcab MERGE trunk -r682:685 -> branches/stable-1.1 (Fixed dist files, source docs, version 1.1.1)
Florian Pose <fp@igh-essen.com>
parents: 1732
diff changeset
    94
/** \cond */
1732
1cc865ba17c2 MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents: 1719
diff changeset
    95
void ec_fsm_slaveconf_state_start(ec_fsm_t *);
1cc865ba17c2 MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents: 1719
diff changeset
    96
void ec_fsm_slave_state_end(ec_fsm_t *);
1cc865ba17c2 MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents: 1719
diff changeset
    97
void ec_fsm_slave_state_error(ec_fsm_t *);
1733
69f0fbc0dcab MERGE trunk -r682:685 -> branches/stable-1.1 (Fixed dist files, source docs, version 1.1.1)
Florian Pose <fp@igh-essen.com>
parents: 1732
diff changeset
    98
/** \endcond */
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 293
diff changeset
    99
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
/*****************************************************************************/
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
#endif