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@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@830: #include "../include/ecrt.h" fp@830: fp@325: #include "globals.h" fp@293: #include "datagram.h" fp@847: #include "sdo_request.h" fp@830: #include "fsm_slave_config.h" fp@830: #include "fsm_slave_scan.h" fp@741: #include "fsm_coe_map.h" fp@433: fp@238: /*****************************************************************************/ fp@238: fp@872: /** SII write request. fp@601: */ fp@830: typedef struct { fp@758: struct list_head list; /**< list head */ fp@758: ec_slave_t *slave; /**< EtherCAT slave */ fp@758: off_t word_offset; /**< SII address in words */ fp@758: size_t word_size; /**< data size in words */ fp@758: const uint8_t *data; /**< pointer to the data */ fp@758: ec_request_state_t state; /**< state of the request */ fp@872: } ec_sii_write_request_t; fp@601: fp@601: /*****************************************************************************/ fp@601: fp@849: /** Slave/Sdo request record for master's Sdo request list. fp@849: */ fp@849: typedef struct { fp@849: struct list_head list; /**< List element. */ fp@849: ec_slave_t *slave; /**< Slave. */ fp@849: ec_sdo_request_t req; /**< Sdo request. */ fp@849: } ec_master_sdo_request_t; fp@849: fp@849: /*****************************************************************************/ fp@849: 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@650: int idle; /**< state machine is in idle phase */ fp@652: unsigned long scan_jiffies; /**< beginning of slave scanning */ fp@528: unsigned int slaves_responding; /**< number of responding slaves */ fp@553: unsigned int topology_change_pending; /**< bus topology changed */ fp@528: ec_slave_state_t slave_states; /**< states of responding slaves */ fp@528: unsigned int validate; /**< non-zero, if validation to do */ fp@612: unsigned int tainted; /**< non-zero, if the current bus topology does fp@612: not meet the initial conditions */ fp@656: unsigned int config_error; /**< error during slave configuration */ 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@858: ec_sdo_request_t *sdo_request; /**< Sdo request to process. */ fp@238: 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@434: ec_fsm_change_t fsm_change; /**< State change state machine */ fp@436: ec_fsm_coe_t fsm_coe; /**< CoE state machine */ fp@741: ec_fsm_coe_map_t fsm_coe_map; /**< CoE mapping 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@528: int ec_fsm_master_exec(ec_fsm_master_t *); fp@650: int ec_fsm_master_running(const 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