fp@238: /****************************************************************************** fp@238: * fp@238: * $Id$ fp@238: * fp@238: * Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH fp@238: * fp@238: * This file is part of the IgH EtherCAT Master. fp@238: * fp@238: * The IgH EtherCAT Master is free software; you can redistribute it fp@238: * and/or modify it under the terms of the GNU General Public License fp@246: * as published by the Free Software Foundation; either version 2 of the fp@246: * License, or (at your option) any later version. fp@238: * fp@238: * The IgH EtherCAT Master is distributed in the hope that it will be fp@238: * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of fp@238: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the fp@238: * GNU General Public License for more details. fp@238: * fp@238: * You should have received a copy of the GNU General Public License fp@238: * along with the IgH EtherCAT Master; if not, write to the Free Software fp@238: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA fp@238: * fp@246: * The right to use EtherCAT Technology is granted and comes free of fp@246: * charge under condition of compatibility of product made by fp@246: * Licensee. People intending to distribute/sell products based on the fp@246: * code, have to sign an agreement to guarantee that products using fp@246: * software based on IgH EtherCAT master stay compatible with the actual fp@246: * EtherCAT specification (which are released themselves as an open fp@246: * standard) as the (only) precondition to have the right to use EtherCAT fp@246: * Technology, IP and trade marks. fp@246: * fp@238: *****************************************************************************/ fp@238: fp@238: /** fp@238: \file fp@238: EtherCAT finite state machines. fp@238: */ fp@238: fp@238: /*****************************************************************************/ fp@238: fp@238: #ifndef __EC_STATES__ fp@238: #define __EC_STATES__ fp@238: fp@1715: #include "globals.h" fp@238: #include "../include/ecrt.h" fp@293: #include "datagram.h" fp@238: #include "slave.h" fp@1732: #include "canopen.h" fp@1732: fp@1732: #include "fsm_sii.h" fp@1732: #include "fsm_change.h" fp@1732: #include "fsm_coe.h" fp@238: fp@238: /*****************************************************************************/ fp@238: fp@286: typedef struct ec_fsm ec_fsm_t; /**< \see ec_fsm */ fp@238: fp@238: /** fp@238: Finite state machine of an EtherCAT master. fp@238: */ fp@238: fp@238: struct ec_fsm fp@238: { fp@238: ec_master_t *master; /**< master the FSM runs on */ fp@238: ec_slave_t *slave; /**< slave the FSM runs on */ fp@293: ec_datagram_t datagram; /**< datagram used in the state machine */ fp@238: fp@238: void (*master_state)(ec_fsm_t *); /**< master state function */ fp@238: unsigned int master_slaves_responding; /**< number of responding slaves */ fp@238: ec_slave_state_t master_slave_states; /**< states of responding slaves */ fp@260: unsigned int master_validation; /**< non-zero, if validation to do */ fp@1732: uint16_t sii_offset; /**< current offset for SII access */ fp@1732: ec_sdo_request_t *sdo_request; fp@238: fp@238: void (*slave_state)(ec_fsm_t *); /**< slave state function */ fp@1732: ec_sdo_data_t *sdodata; /**< SDO configuration data */ fp@238: fp@1732: ec_fsm_sii_t fsm_sii; /**< SII state machine */ fp@1732: ec_fsm_change_t fsm_change; /**< State change state machine */ fp@1732: ec_fsm_coe_t fsm_coe; /**< CoE state machine */ fp@238: }; fp@238: fp@238: /*****************************************************************************/ fp@238: fp@238: int ec_fsm_init(ec_fsm_t *, ec_master_t *); fp@238: void ec_fsm_clear(ec_fsm_t *); fp@238: fp@1732: int ec_fsm_exec(ec_fsm_t *); fp@1732: int ec_fsm_running(ec_fsm_t *); fp@1732: int ec_fsm_success(ec_fsm_t *); fp@1715: fp@1732: // TODO: layout slave state machines fp@1733: fp@1733: /** \cond */ fp@1732: void ec_fsm_slaveconf_state_start(ec_fsm_t *); fp@1732: void ec_fsm_slave_state_end(ec_fsm_t *); fp@1732: void ec_fsm_slave_state_error(ec_fsm_t *); fp@1733: /** \endcond */ fp@1715: fp@238: /*****************************************************************************/ fp@238: fp@238: #endif