master/fsm_slave.h
author Florian Pose <fp@igh-essen.com>
Tue, 19 Feb 2008 16:24:45 +0000
changeset 803 c9e147567924
parent 802 b947d0b09f9a
child 814 a51f857b1b2d
permissions -rw-r--r--
Updated properties and keywords for dot files.
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
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 505
diff changeset
    41
#ifndef __EC_FSM_SLAVE__
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 505
diff changeset
    42
#define __EC_FSM_SLAVE__
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
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"
433
100f51f28cf2 Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
    48
#include "fsm_sii.h"
434
0180d8277311 Layed out state change state machine.
Florian Pose <fp@igh-essen.com>
parents: 433
diff changeset
    49
#include "fsm_change.h"
436
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 435
diff changeset
    50
#include "fsm_coe.h"
802
b947d0b09f9a Renamed ec_fsm_mapping_t to ec_fsm_pdo_mapping_t.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    51
#include "fsm_pdo_mapping.h"
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    52
#include "fsm_pdo_config.h"
433
100f51f28cf2 Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
    53
238
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
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 505
diff changeset
    56
typedef struct ec_fsm_slave ec_fsm_slave_t; /**< \see ec_fsm_slave */
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    58
/** Finite state machine of an EtherCAT slave.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    59
 */
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 505
diff changeset
    60
struct ec_fsm_slave
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
{
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    62
    ec_slave_t *slave; /**< Slave the FSM runs on. */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    63
    ec_datagram_t *datagram; /**< Datagram used in the state machine. */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    64
    unsigned int retries; /**< Retries on datagram timeout. */
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    66
    void (*state)(ec_fsm_slave_t *); /**< State function. */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    67
    ec_sdo_data_t *sdodata; /**< SDO configuration data. */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    68
    uint16_t sii_offset; /**< SII offset in words. */
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    70
    ec_fsm_sii_t fsm_sii; /**< SII state machine. */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    71
    ec_fsm_change_t fsm_change; /**< State change state machine. */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    72
    ec_fsm_coe_t fsm_coe; /**< CoE state machine. */
802
b947d0b09f9a Renamed ec_fsm_mapping_t to ec_fsm_pdo_mapping_t.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    73
    ec_fsm_pdo_mapping_t fsm_pdo_map; /**< Pdo mapping state machine. */
b947d0b09f9a Renamed ec_fsm_mapping_t to ec_fsm_pdo_mapping_t.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    74
    ec_fsm_pdo_config_t fsm_pdo_conf; /**< Pdo configuration state machine. */
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
};
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
/*****************************************************************************/
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 505
diff changeset
    79
void ec_fsm_slave_init(ec_fsm_slave_t *, ec_datagram_t *);
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 505
diff changeset
    80
void ec_fsm_slave_clear(ec_fsm_slave_t *);
446
8fede404c01f Persistent slave lists.
Florian Pose <fp@igh-essen.com>
parents: 436
diff changeset
    81
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 505
diff changeset
    82
void ec_fsm_slave_start_scan(ec_fsm_slave_t *, ec_slave_t *);
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 505
diff changeset
    83
void ec_fsm_slave_start_conf(ec_fsm_slave_t *, ec_slave_t *);
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 293
diff changeset
    84
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 505
diff changeset
    85
int ec_fsm_slave_exec(ec_fsm_slave_t *);
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 505
diff changeset
    86
int ec_fsm_slave_success(const ec_fsm_slave_t *);
456
dea14706efc2 Explicit use of slave configuration FSM in ecrt_master_activate() and ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents: 446
diff changeset
    87
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
/*****************************************************************************/
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
#endif