IgH EtherCAT Master  1.6.2
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 
27 /****************************************************************************/
28 
29 #ifndef __EC_FSM_MASTER_H__
30 #define __EC_FSM_MASTER_H__
31 
32 #include "globals.h"
33 #include "datagram.h"
34 #include "foe_request.h"
35 #include "sdo_request.h"
36 #include "soe_request.h"
37 #include "fsm_slave_config.h"
38 #include "fsm_slave_scan.h"
39 #include "fsm_pdo.h"
40 
41 /****************************************************************************/
42 
45 typedef struct {
46  struct list_head list;
48  uint16_t offset;
49  size_t nwords;
50  const uint16_t *words;
53 
54 /****************************************************************************/
55 
60 struct ec_fsm_master {
63  unsigned int retries;
65  void (*state)(ec_fsm_master_t *);
68  int idle;
69  unsigned long scan_jiffies;
70  uint8_t link_state[EC_MAX_NUM_DEVICES];
72  unsigned int slaves_responding[EC_MAX_NUM_DEVICES];
75  unsigned int rescan_required;
76  ec_slave_state_t slave_states[EC_MAX_NUM_DEVICES];
81  off_t sii_index;
93 };
94 
95 /****************************************************************************/
96 
99 
101 
104 
105 /****************************************************************************/
106 
107 #endif
Finite state machines for the Sercos over EtherCAT protocol.
Definition: fsm_soe.h:43
uint16_t offset
SII word offset.
Definition: fsm_master.h:48
ec_datagram_t * datagram
datagram used in the state machine
Definition: fsm_master.h:62
void ec_fsm_master_clear(ec_fsm_master_t *)
Destructor.
Definition: fsm_master.c:123
ec_sii_write_request_t * sii_request
SII write request.
Definition: fsm_master.h:80
ec_fsm_soe_t fsm_soe
SoE state machine.
Definition: fsm_master.h:86
ec_fsm_pdo_t fsm_pdo
PDO configuration state machine.
Definition: fsm_master.h:87
Finite state machine of an EtherCAT master.
Definition: fsm_master.h:60
ec_internal_request_state_t state
State of the request.
Definition: fsm_master.h:51
unsigned int slaves_responding[EC_MAX_NUM_DEVICES]
Number of responding slaves for every device.
Definition: fsm_master.h:72
CANopen SDO request.
Definition: sdo_request.h:40
Slave information interface FSM.
Definition: fsm_sii.h:53
void(* state)(ec_fsm_master_t *)
master state function
Definition: fsm_master.h:65
size_t nwords
Number of words.
Definition: fsm_master.h:49
unsigned int rescan_required
A bus rescan is required.
Definition: fsm_master.h:75
EtherCAT datagram.
Definition: datagram.h:79
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:76
EtherCAT slave scanning state machine.
SII write request.
Definition: fsm_master.h:45
int ec_fsm_master_idle(const ec_fsm_master_t *)
Definition: fsm_master.c:192
Global definitions and macros.
ec_internal_request_state_t
Generic request state.
Definition: globals.h:287
int ec_fsm_master_exec(ec_fsm_master_t *)
Executes the current state of the state machine.
Definition: fsm_master.c:173
ec_slave_t * slave
EtherCAT slave.
Definition: fsm_master.h:47
void ec_fsm_master_init(ec_fsm_master_t *, ec_master_t *, ec_datagram_t *)
Constructor.
Definition: fsm_master.c:82
EtherCAT slave.
Definition: slave.h:168
EtherCAT slave configuration state machine.
ec_fsm_sii_t fsm_sii
SII state machine.
Definition: fsm_master.h:92
ec_fsm_eoe_t fsm_eoe
EoE state machine.
Definition: fsm_master.h:88
ec_fsm_slave_scan_t fsm_slave_scan
slave state machine
Definition: fsm_master.h:91
EtherCAT CANopen SDO request structure.
ec_sdo_request_t * sdo_request
SDO request to process.
Definition: fsm_master.h:82
ec_device_index_t
Master devices.
Definition: globals.h:198
ec_soe_request_t * soe_request
SoE request to process.
Definition: fsm_master.h:83
unsigned long scan_jiffies
beginning of slave scanning
Definition: fsm_master.h:69
EtherCAT FoE request structure.
Finite state machine for scanning an EtherCAT slave.
ec_slave_state_t
State of an EtherCAT slave.
Definition: globals.h:121
EtherCAT datagram structure.
PDO configuration state machine.
Definition: fsm_pdo.h:46
void ec_fsm_master_reset(ec_fsm_master_t *)
Reset state machine.
Definition: fsm_master.c:144
int idle
state machine is in idle phase
Definition: fsm_master.h:68
ec_fsm_slave_config_t fsm_slave_config
slave state machine
Definition: fsm_master.h:90
Finite state machine to configure an EtherCAT slave.
ec_master_t * master
master the FSM runs on
Definition: fsm_master.h:61
unsigned int retries
retries on datagram timeout.
Definition: fsm_master.h:63
EtherCAT SoE request structure.
ec_slave_t * slave
current slave
Definition: fsm_master.h:79
ec_fsm_change_t fsm_change
State change state machine.
Definition: fsm_master.h:89
off_t sii_index
index to SII write request data
Definition: fsm_master.h:81
EtherCAT master.
Definition: master.h:187
ec_device_index_t dev_idx
Current device index (for scanning etc.).
Definition: fsm_master.h:66
const uint16_t * words
Pointer to the data words.
Definition: fsm_master.h:50
Sercos-over-EtherCAT request.
Definition: soe_request.h:40
EtherCAT state change FSM.
Definition: fsm_change.h:56
uint8_t link_state[EC_MAX_NUM_DEVICES]
Last link state for every device.
Definition: fsm_master.h:70
ec_fsm_coe_t fsm_coe
CoE state machine.
Definition: fsm_master.h:85
Finite state machines for the Ethernet over EtherCAT protocol.
Definition: fsm_eoe.h:43
Finite state machines for the CANopen over EtherCAT protocol.
Definition: fsm_coe.h:44