IgH EtherCAT Master  1.5.3
fsm_master.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * Copyright (C) 2006-2023 Florian Pose, Ingenieurgemeinschaft IgH
4  *
5  * This file is part of the IgH EtherCAT Master.
6  *
7  * The IgH EtherCAT Master is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License version 2, as
9  * published by the Free Software Foundation.
10  *
11  * The IgH EtherCAT Master is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14  * Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with the IgH EtherCAT Master; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  *
20  * ---
21  *
22  * The license mentioned above concerns the source code only. Using the
23  * EtherCAT technology and brand is only permitted in compliance with the
24  * industrial property and similar rights of Beckhoff Automation GmbH.
25  *
26  *****************************************************************************/
27 
33 /*****************************************************************************/
34 
35 #ifndef __EC_FSM_MASTER_H__
36 #define __EC_FSM_MASTER_H__
37 
38 #include "globals.h"
39 #include "datagram.h"
40 #include "foe_request.h"
41 #include "sdo_request.h"
42 #include "soe_request.h"
43 #include "fsm_slave_config.h"
44 #include "fsm_slave_scan.h"
45 #include "fsm_pdo.h"
46 
47 /*****************************************************************************/
48 
51 typedef struct {
52  struct list_head list;
54  uint16_t offset;
55  size_t nwords;
56  const uint16_t *words;
59 
60 /*****************************************************************************/
61 
66 struct ec_fsm_master {
69  unsigned int retries;
71  void (*state)(ec_fsm_master_t *);
74  int idle;
75  unsigned long scan_jiffies;
76  uint8_t link_state[EC_MAX_NUM_DEVICES];
78  unsigned int slaves_responding[EC_MAX_NUM_DEVICES];
81  unsigned int rescan_required;
82  ec_slave_state_t slave_states[EC_MAX_NUM_DEVICES];
87  off_t sii_index;
98 };
99 
100 /*****************************************************************************/
101 
104 
106 
109 
110 /*****************************************************************************/
111 
112 #endif
Finite state machines for the Sercos over EtherCAT protocol.
Definition: fsm_soe.h:51
uint16_t offset
SII word offset.
Definition: fsm_master.h:54
ec_datagram_t * datagram
datagram used in the state machine
Definition: fsm_master.h:68
void ec_fsm_master_clear(ec_fsm_master_t *)
Destructor.
Definition: fsm_master.c:113
ec_sii_write_request_t * sii_request
SII write request.
Definition: fsm_master.h:86
ec_fsm_soe_t fsm_soe
SoE state machine.
Definition: fsm_master.h:92
ec_fsm_pdo_t fsm_pdo
PDO configuration state machine.
Definition: fsm_master.h:93
Finite state machine of an EtherCAT master.
Definition: fsm_master.h:66
ec_internal_request_state_t state
State of the request.
Definition: fsm_master.h:57
unsigned int slaves_responding[EC_MAX_NUM_DEVICES]
Number of responding slaves for every device.
Definition: fsm_master.h:78
CANopen SDO request.
Definition: sdo_request.h:46
Slave information interface FSM.
Definition: fsm_sii.h:61
void(* state)(ec_fsm_master_t *)
master state function
Definition: fsm_master.h:71
size_t nwords
Number of words.
Definition: fsm_master.h:55
unsigned int rescan_required
A bus rescan is required.
Definition: fsm_master.h:81
EtherCAT datagram.
Definition: datagram.h:87
EtherCAT PDO configuration state machine structures.
ec_slave_state_t slave_states[EC_MAX_NUM_DEVICES]
AL states of responding slaves for every device.
Definition: fsm_master.h:82
EtherCAT slave scanning state machine.
SII write request.
Definition: fsm_master.h:51
int ec_fsm_master_idle(const ec_fsm_master_t *)
Definition: fsm_master.c:179
Global definitions and macros.
ec_internal_request_state_t
Generic request state.
Definition: globals.h:278
int ec_fsm_master_exec(ec_fsm_master_t *)
Executes the current state of the state machine.
Definition: fsm_master.c:160
ec_slave_t * slave
EtherCAT slave.
Definition: fsm_master.h:53
void ec_fsm_master_init(ec_fsm_master_t *, ec_master_t *, ec_datagram_t *)
Constructor.
Definition: fsm_master.c:76
EtherCAT slave.
Definition: slave.h:176
EtherCAT slave configuration state machine.
ec_fsm_sii_t fsm_sii
SII state machine.
Definition: fsm_master.h:97
ec_fsm_slave_scan_t fsm_slave_scan
slave state machine
Definition: fsm_master.h:96
EtherCAT CANopen SDO request structure.
ec_sdo_request_t * sdo_request
SDO request to process.
Definition: fsm_master.h:88
ec_device_index_t
Master devices.
Definition: globals.h:189
ec_soe_request_t * soe_request
SoE request to process.
Definition: fsm_master.h:89
unsigned long scan_jiffies
beginning of slave scanning
Definition: fsm_master.h:75
EtherCAT FoE request structure.
Finite state machine for scanning an EtherCAT slave.
ec_slave_state_t
State of an EtherCAT slave.
Definition: globals.h:115
EtherCAT datagram structure.
PDO configuration state machine.
Definition: fsm_pdo.h:54
void ec_fsm_master_reset(ec_fsm_master_t *)
Reset state machine.
Definition: fsm_master.c:131
int idle
state machine is in idle phase
Definition: fsm_master.h:74
ec_fsm_slave_config_t fsm_slave_config
slave state machine
Definition: fsm_master.h:95
Finite state machine to configure an EtherCAT slave.
ec_master_t * master
master the FSM runs on
Definition: fsm_master.h:67
unsigned int retries
retries on datagram timeout.
Definition: fsm_master.h:69
EtherCAT SoE request structure.
ec_slave_t * slave
current slave
Definition: fsm_master.h:85
ec_fsm_change_t fsm_change
State change state machine.
Definition: fsm_master.h:94
off_t sii_index
index to SII write request data
Definition: fsm_master.h:87
EtherCAT master.
Definition: master.h:194
ec_device_index_t dev_idx
Current device index (for scanning etc.).
Definition: fsm_master.h:72
const uint16_t * words
Pointer to the data words.
Definition: fsm_master.h:56
Sercos-over-EtherCAT request.
Definition: soe_request.h:48
EtherCAT state change FSM.
Definition: fsm_change.h:64
uint8_t link_state[EC_MAX_NUM_DEVICES]
Last link state for every device.
Definition: fsm_master.h:76
ec_fsm_coe_t fsm_coe
CoE state machine.
Definition: fsm_master.h:91
Finite state machines for the CANopen over EtherCAT protocol.
Definition: fsm_coe.h:52