fp@1707: /****************************************************************************** fp@1707: * fp@1707: * $Id:$ fp@1707: * fp@1707: * Copyright (C) 2008 Olav Zarges, imc Meßsysteme GmbH fp@1707: * fp@1707: * This file is part of the IgH EtherCAT Master. fp@1707: * fp@1707: * The IgH EtherCAT Master is free software; you can redistribute it fp@1707: * and/or modify it under the terms of the GNU General Public License fp@1707: * as published by the Free Software Foundation; either version 2 of the fp@1707: * License, or (at your option) any later version. fp@1707: * fp@1707: * The IgH EtherCAT Master is distributed in the hope that it will be fp@1707: * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of fp@1707: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the fp@1707: * GNU General Public License for more details. fp@1707: * fp@1707: * You should have received a copy of the GNU General Public License fp@1707: * along with the IgH EtherCAT Master; if not, write to the Free Software fp@1707: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA fp@1707: * fp@1707: * The right to use EtherCAT Technology is granted and comes free of fp@1707: * charge under condition of compatibility of product made by fp@1707: * Licensee. People intending to distribute/sell products based on the fp@1707: * code, have to sign an agreement to guarantee that products using fp@1707: * software based on IgH EtherCAT master stay compatible with the actual fp@1707: * EtherCAT specification (which are released themselves as an open fp@1707: * standard) as the (only) precondition to have the right to use EtherCAT fp@1707: * Technology, IP and trade marks. fp@1707: * fp@1707: *****************************************************************************/ fp@1707: fp@1707: /** fp@1707: \file fp@1707: EtherCAT FoE state machines. fp@1707: */ fp@1707: fp@1707: /*****************************************************************************/ fp@1707: fp@1707: #ifndef __EC_FSM_FOE_H__ fp@1707: #define __EC_FSM_FOE_H__ fp@1707: fp@1707: #include "globals.h" fp@1707: #include "../include/ecrt.h" fp@1707: #include "datagram.h" fp@1707: #include "slave.h" fp@1707: #include "foe_request.h" fp@1707: fp@1707: /*****************************************************************************/ fp@1707: fp@1707: typedef struct ec_fsm_foe ec_fsm_foe_t; /**< \see ec_fsm_foe */ fp@1707: fp@1707: /** Finite state machines for the CANopen-over-EtherCAT protocol. fp@1707: */ fp@1707: struct ec_fsm_foe { fp@1707: ec_slave_t *slave; /**< slave the FSM runs on */ fp@1707: ec_datagram_t *datagram; /**< datagram used in the state machine */ fp@1707: unsigned int retries; /**< retries upon datagram timeout */ fp@1707: fp@1707: void (*state)(ec_fsm_foe_t *); /**< FoE state function */ fp@1707: unsigned long jiffies_start; /**< FoE timestamp. */ fp@1707: uint8_t subindex; /**< current subindex */ fp@1707: ec_foe_request_t *request; /**< FoE request */ fp@1707: uint8_t toggle; /**< toggle bit for segment commands */ fp@1707: fp@1707: uint32_t tx_errors; fp@1707: uint8_t *tx_buffer; fp@1707: uint32_t tx_buffer_size; fp@1707: uint32_t tx_buffer_offset; fp@1707: uint32_t tx_last_packet; fp@1707: uint32_t tx_packet_no; fp@1707: uint32_t tx_current_size; fp@1707: uint8_t *tx_filename; fp@1707: uint32_t tx_filename_len; fp@1707: fp@1707: fp@1707: uint32_t rx_errors; fp@1707: uint8_t *rx_buffer; fp@1707: uint32_t rx_buffer_size; fp@1707: uint32_t rx_buffer_offset; fp@1707: uint32_t rx_current_size; fp@1707: uint32_t rx_packet_no; fp@1707: uint32_t rx_expected_packet_no; fp@1707: uint32_t rx_last_packet; fp@1707: uint8_t *rx_filename; fp@1707: uint32_t rx_filename_len; fp@1707: }; fp@1707: fp@1707: /*****************************************************************************/ fp@1707: fp@1707: void ec_fsm_foe_init(ec_fsm_foe_t *, ec_datagram_t *); fp@1707: void ec_fsm_foe_clear(ec_fsm_foe_t *); fp@1707: fp@1707: int ec_fsm_foe_exec(ec_fsm_foe_t *); fp@1707: int ec_fsm_foe_success(ec_fsm_foe_t *); fp@1707: fp@1707: void ec_fsm_foe_transfer(ec_fsm_foe_t *, ec_slave_t *, ec_foe_request_t *); fp@1707: fp@1707: /*****************************************************************************/ fp@1707: fp@1707: #endif