fp@238: /****************************************************************************** fp@238: * fp@238: * $Id$ fp@238: * fp@2443: * Copyright (C) 2006-2012 Florian Pose, Ingenieurgemeinschaft IgH fp@238: * fp@238: * This file is part of the IgH EtherCAT Master. fp@238: * 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@238: * 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@238: * 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@238: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA fp@238: * 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@246: * fp@238: *****************************************************************************/ fp@238: fp@238: /** fp@238: \file fp@830: EtherCAT master state machine. fp@238: */ fp@238: fp@238: /*****************************************************************************/ fp@238: fp@883: #ifndef __EC_FSM_MASTER_H__ fp@883: #define __EC_FSM_MASTER_H__ fp@238: fp@325: #include "globals.h" fp@293: #include "datagram.h" fp@1335: #include "foe_request.h" fp@847: #include "sdo_request.h" fp@1831: #include "soe_request.h" fp@830: #include "fsm_slave_config.h" fp@830: #include "fsm_slave_scan.h" fp@1174: #include "fsm_pdo.h" fp@433: fp@238: /*****************************************************************************/ fp@238: fp@872: /** SII write request. fp@601: */ fp@830: typedef struct { fp@979: struct list_head list; /**< List head. */ fp@979: ec_slave_t *slave; /**< EtherCAT slave. */ fp@979: uint16_t offset; /**< SII word offset. */ fp@979: size_t nwords; /**< Number of words. */ fp@979: const uint16_t *words; /**< Pointer to the data words. */ fp@1209: ec_internal_request_state_t state; /**< State of the request. */ fp@872: } ec_sii_write_request_t; fp@601: fp@601: /*****************************************************************************/ fp@601: fp@528: typedef struct ec_fsm_master ec_fsm_master_t; /**< \see ec_fsm_master */ fp@238: fp@830: /** Finite state machine of an EtherCAT master. fp@830: */ fp@830: struct ec_fsm_master { fp@238: ec_master_t *master; /**< master the FSM runs on */ fp@528: ec_datagram_t *datagram; /**< datagram used in the state machine */ fp@505: unsigned int retries; /**< retries on datagram timeout. */ fp@238: fp@528: void (*state)(ec_fsm_master_t *); /**< master state function */ fp@2374: ec_device_index_t dev_idx; /**< Current device index (for scanning etc.). fp@2374: */ fp@650: int idle; /**< state machine is in idle phase */ fp@652: unsigned long scan_jiffies; /**< beginning of slave scanning */ fp@2453: uint8_t link_state[EC_MAX_NUM_DEVICES]; /**< Last link state for every fp@2453: device. */ fp@2453: unsigned int slaves_responding[EC_MAX_NUM_DEVICES]; /**< Number of fp@2453: responding slaves fp@2453: for every device. */ fp@1961: unsigned int rescan_required; /**< A bus rescan is required. */ fp@2453: ec_slave_state_t slave_states[EC_MAX_NUM_DEVICES]; /**< AL states of fp@2453: responding slaves for fp@2453: every device. */ fp@528: ec_slave_t *slave; /**< current slave */ fp@872: ec_sii_write_request_t *sii_request; /**< SII write request */ fp@872: off_t sii_index; /**< index to SII write request data */ fp@1327: ec_sdo_request_t *sdo_request; /**< SDO request to process. */ fp@238: fp@1174: ec_fsm_coe_t fsm_coe; /**< CoE state machine */ fp@2482: ec_fsm_soe_t fsm_soe; /**< SoE state machine */ fp@1327: ec_fsm_pdo_t fsm_pdo; /**< PDO configuration state machine. */ fp@1174: ec_fsm_change_t fsm_change; /**< State change state machine */ fp@830: ec_fsm_slave_config_t fsm_slave_config; /**< slave state machine */ fp@830: ec_fsm_slave_scan_t fsm_slave_scan; /**< slave state machine */ fp@433: ec_fsm_sii_t fsm_sii; /**< SII state machine */ fp@238: }; fp@238: fp@238: /*****************************************************************************/ fp@238: fp@528: void ec_fsm_master_init(ec_fsm_master_t *, ec_master_t *, ec_datagram_t *); fp@528: void ec_fsm_master_clear(ec_fsm_master_t *); fp@446: fp@2456: void ec_fsm_master_reset(ec_fsm_master_t *); fp@2456: martin@1583: int ec_fsm_master_exec(ec_fsm_master_t *); fp@650: int ec_fsm_master_idle(const ec_fsm_master_t *); fp@456: fp@238: /*****************************************************************************/ fp@238: fp@238: #endif