fp@1739: /****************************************************************************** fp@1739: * fp@1739: * $Id$ fp@1739: * fp@1739: * Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH fp@1739: * fp@1739: * This file is part of the IgH EtherCAT Master. fp@1739: * fp@1739: * The IgH EtherCAT Master is free software; you can redistribute it fp@1739: * and/or modify it under the terms of the GNU General Public License fp@1739: * as published by the Free Software Foundation; either version 2 of the fp@1739: * License, or (at your option) any later version. fp@1739: * fp@1739: * The IgH EtherCAT Master is distributed in the hope that it will be fp@1739: * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of fp@1739: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the fp@1739: * GNU General Public License for more details. fp@1739: * fp@1739: * You should have received a copy of the GNU General Public License fp@1739: * along with the IgH EtherCAT Master; if not, write to the Free Software fp@1739: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA fp@1739: * fp@1739: * The right to use EtherCAT Technology is granted and comes free of fp@1739: * charge under condition of compatibility of product made by fp@1739: * Licensee. People intending to distribute/sell products based on the fp@1739: * code, have to sign an agreement to guarantee that products using fp@1739: * software based on IgH EtherCAT master stay compatible with the actual fp@1739: * EtherCAT specification (which are released themselves as an open fp@1739: * standard) as the (only) precondition to have the right to use EtherCAT fp@1739: * Technology, IP and trade marks. fp@1739: * fp@1739: *****************************************************************************/ fp@1739: fp@1739: /** fp@1739: \file fp@1739: EtherCAT finite state machines. fp@1739: */ fp@1739: fp@1739: /*****************************************************************************/ fp@1739: fp@1739: #ifndef __EC_FSM_MASTER__ fp@1739: #define __EC_FSM_MASTER__ fp@1739: fp@1739: #include "globals.h" fp@1739: #include "../include/ecrt.h" fp@1739: #include "datagram.h" fp@1739: #include "slave.h" fp@1739: #include "canopen.h" fp@1739: fp@1739: #include "fsm_slave.h" fp@1739: fp@1739: /*****************************************************************************/ fp@1739: fp@1739: typedef struct ec_fsm_master ec_fsm_master_t; /**< \see ec_fsm_master */ fp@1739: fp@1739: /** fp@1739: Finite state machine of an EtherCAT master. fp@1739: */ fp@1739: fp@1739: struct ec_fsm_master fp@1739: { fp@1739: ec_master_t *master; /**< master the FSM runs on */ fp@1739: ec_datagram_t *datagram; /**< datagram used in the state machine */ fp@1739: unsigned int retries; /**< retries on datagram timeout. */ fp@1739: fp@1739: void (*state)(ec_fsm_master_t *); /**< master state function */ fp@1739: unsigned int slaves_responding; /**< number of responding slaves */ fp@1739: unsigned int topology_change_pending; /**< bus topology changed */ fp@1739: ec_slave_state_t slave_states; /**< states of responding slaves */ fp@1739: unsigned int validate; /**< non-zero, if validation to do */ fp@1739: ec_slave_t *slave; /**< current slave */ fp@1739: ec_sdo_request_t *sdo_request; /**< SDO request to process */ fp@1739: uint16_t sii_offset; fp@1739: fp@1739: ec_fsm_slave_t fsm_slave; /**< slave state machine */ fp@1739: ec_fsm_sii_t fsm_sii; /**< SII state machine */ fp@1739: ec_fsm_change_t fsm_change; /**< State change state machine */ fp@1739: ec_fsm_coe_t fsm_coe; /**< CoE state machine */ fp@1739: }; fp@1739: fp@1739: /*****************************************************************************/ fp@1739: fp@1739: void ec_fsm_master_init(ec_fsm_master_t *, ec_master_t *, ec_datagram_t *); fp@1739: void ec_fsm_master_clear(ec_fsm_master_t *); fp@1739: fp@1739: int ec_fsm_master_exec(ec_fsm_master_t *); fp@1739: int ec_fsm_master_running(ec_fsm_master_t *); fp@1739: int ec_fsm_master_success(ec_fsm_master_t *); fp@1739: fp@1739: /*****************************************************************************/ fp@1739: fp@1739: #endif