fp@434: /****************************************************************************** fp@434: * fp@434: * $Id$ fp@434: * fp@1326: * Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH fp@434: * fp@434: * This file is part of the IgH EtherCAT Master. fp@434: * fp@1326: * The IgH EtherCAT Master is free software; you can redistribute it and/or fp@1326: * modify it under the terms of the GNU General Public License version 2, as fp@1326: * published by the Free Software Foundation. fp@434: * fp@1326: * The IgH EtherCAT Master is distributed in the hope that it will be useful, fp@1326: * but WITHOUT ANY WARRANTY; without even the implied warranty of fp@1326: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General fp@1326: * Public License for more details. fp@434: * fp@1326: * You should have received a copy of the GNU General Public License along fp@1326: * with the IgH EtherCAT Master; if not, write to the Free Software fp@434: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA fp@434: * fp@1363: * --- fp@1363: * fp@1363: * The license mentioned above concerns the source code only. Using the fp@1363: * EtherCAT technology and brand is only permitted in compliance with the fp@1363: * industrial property and similar rights of Beckhoff Automation GmbH. fp@434: * fp@434: *****************************************************************************/ fp@434: fp@434: /** fp@434: \file fp@434: EtherCAT state change FSM. fp@434: */ fp@434: fp@434: /*****************************************************************************/ fp@434: fp@883: #ifndef __EC_FSM_CHANGE_H__ fp@883: #define __EC_FSM_CHANGE_H__ fp@434: fp@434: #include "globals.h" fp@434: #include "datagram.h" fp@434: #include "slave.h" fp@434: fp@434: /*****************************************************************************/ fp@434: fp@454: /** fp@454: Mode of the change state machine. fp@454: */ fp@454: fp@454: typedef enum { fp@454: EC_FSM_CHANGE_MODE_FULL, /**< full state change */ fp@454: EC_FSM_CHANGE_MODE_ACK_ONLY /**< only state acknowledgement */ fp@454: } fp@454: ec_fsm_change_mode_t; fp@454: fp@454: /*****************************************************************************/ fp@454: fp@434: typedef struct ec_fsm_change ec_fsm_change_t; /**< \see ec_fsm_change */ fp@434: fp@434: /** fp@434: EtherCAT state change FSM. fp@434: */ fp@434: fp@434: struct ec_fsm_change fp@434: { fp@434: ec_slave_t *slave; /**< slave the FSM runs on */ fp@434: ec_datagram_t *datagram; /**< datagram used in the state machine */ fp@505: unsigned int retries; /**< retries upon datagram timeout */ fp@434: fp@434: void (*state)(ec_fsm_change_t *); /**< slave state change state function */ fp@454: ec_fsm_change_mode_t mode; /**< full state change, or ack only. */ fp@434: ec_slave_state_t requested_state; /**< input: state */ fp@454: ec_slave_state_t old_state; /**< prior slave state */ fp@434: unsigned long jiffies_start; /**< change timer */ fp@434: uint8_t take_time; /**< take sending timestamp */ fp@738: uint8_t spontaneous_change; /**< spontaneous state change detected */ fp@434: }; fp@434: fp@434: /*****************************************************************************/ fp@434: fp@434: void ec_fsm_change_init(ec_fsm_change_t *, ec_datagram_t *); fp@434: void ec_fsm_change_clear(ec_fsm_change_t *); fp@434: fp@454: void ec_fsm_change_start(ec_fsm_change_t *, ec_slave_t *, ec_slave_state_t); fp@454: void ec_fsm_change_ack(ec_fsm_change_t *, ec_slave_t *); fp@434: fp@435: int ec_fsm_change_exec(ec_fsm_change_t *); fp@434: int ec_fsm_change_success(ec_fsm_change_t *); fp@434: fp@434: /*****************************************************************************/ fp@434: fp@434: #endif