master/fsm_foe.h
author Philipp Weyer <pw@igh-essen.com>
Fri, 18 Aug 2017 12:30:16 +0200
branchstable-1.5
changeset 2680 e6f324a3d8a0
parent 2498 9cdd7669dc0b
permissions -rw-r--r--
Fixed lib include paths
1335
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
1363
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1335
diff changeset
     3
 *  $Id$
1335
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
2498
9cdd7669dc0b Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents: 1901
diff changeset
     5
 *  Copyright (C) 2008       Olav Zarges, imc Messsysteme GmbH
9cdd7669dc0b Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents: 1901
diff changeset
     6
 *                2009-2012  Florian Pose <fp@igh-essen.com>
1335
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *  This file is part of the IgH EtherCAT Master.
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
 *
1363
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1335
diff changeset
    10
 *  The IgH EtherCAT Master is free software; you can redistribute it and/or
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1335
diff changeset
    11
 *  modify it under the terms of the GNU General Public License version 2, as
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1335
diff changeset
    12
 *  published by the Free Software Foundation.
1335
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
 *
1363
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1335
diff changeset
    14
 *  The IgH EtherCAT Master is distributed in the hope that it will be useful,
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1335
diff changeset
    15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1335
diff changeset
    16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1335
diff changeset
    17
 *  Public License for more details.
1335
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
 *
1363
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1335
diff changeset
    19
 *  You should have received a copy of the GNU General Public License along
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1335
diff changeset
    20
 *  with the IgH EtherCAT Master; if not, write to the Free Software
1335
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
 *
1363
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1335
diff changeset
    23
 *  ---
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1335
diff changeset
    24
 *
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1335
diff changeset
    25
 *  The license mentioned above concerns the source code only. Using the
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1335
diff changeset
    26
 *  EtherCAT technology and brand is only permitted in compliance with the
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1335
diff changeset
    27
 *  industrial property and similar rights of Beckhoff Automation GmbH.
1335
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 *
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
 *****************************************************************************/
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
/**
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
   \file
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
   EtherCAT FoE state machines.
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
*/
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
/*****************************************************************************/
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
#ifndef __EC_FSM_FOE_H__
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
#define __EC_FSM_FOE_H__
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
#include "globals.h"
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
#include "../include/ecrt.h"
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
#include "datagram.h"
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
#include "slave.h"
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
#include "foe_request.h"
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
/*****************************************************************************/
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
typedef struct ec_fsm_foe ec_fsm_foe_t; /**< \see ec_fsm_foe */
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
/** Finite state machines for the CANopen-over-EtherCAT protocol.
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
 */
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
struct ec_fsm_foe {
2498
9cdd7669dc0b Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents: 1901
diff changeset
    54
    ec_slave_t *slave; /**< Slave the FSM runs on. */
9cdd7669dc0b Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents: 1901
diff changeset
    55
    unsigned int retries; /**< Retries upon datagram timeout */
1335
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
2498
9cdd7669dc0b Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents: 1901
diff changeset
    57
    void (*state)(ec_fsm_foe_t *, ec_datagram_t *); /**< FoE state function. */
9cdd7669dc0b Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents: 1901
diff changeset
    58
    ec_datagram_t *datagram; /**< Datagram used in previous step. */
1335
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
    unsigned long jiffies_start; /**< FoE timestamp. */
2498
9cdd7669dc0b Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents: 1901
diff changeset
    60
    uint8_t subindex; /**< Current subindex. */
9cdd7669dc0b Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents: 1901
diff changeset
    61
    ec_foe_request_t *request; /**< FoE request. */
9cdd7669dc0b Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents: 1901
diff changeset
    62
    uint8_t toggle; /**< Toggle bit for segment commands. */
1335
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
1901
2a1106b1d863 Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents: 1465
diff changeset
    64
    uint8_t *tx_buffer; /**< Buffer with data to transmit. */
2a1106b1d863 Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents: 1465
diff changeset
    65
    uint32_t tx_buffer_size; /**< Size of data to transmit. */
2a1106b1d863 Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents: 1465
diff changeset
    66
    uint32_t tx_buffer_offset; /**< Offset of data to tranmit next. */
2a1106b1d863 Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents: 1465
diff changeset
    67
    uint32_t tx_last_packet; /**< Current packet is last one to send. */
2a1106b1d863 Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents: 1465
diff changeset
    68
    uint32_t tx_packet_no; /**< FoE packet number. */
2a1106b1d863 Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents: 1465
diff changeset
    69
    uint32_t tx_current_size; /**< Size of current packet to send. */
2a1106b1d863 Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents: 1465
diff changeset
    70
    uint8_t *tx_filename; /**< Name of file to transmit. */
2a1106b1d863 Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents: 1465
diff changeset
    71
    uint32_t tx_filename_len; /**< Lenth of transmit file name. */
1465
3099d78343ea Added documentation.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    72
1901
2a1106b1d863 Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents: 1465
diff changeset
    73
    uint8_t *rx_buffer; /**< Buffer for received data. */
2a1106b1d863 Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents: 1465
diff changeset
    74
    uint32_t rx_buffer_size; /**< Size of receive buffer. */
2a1106b1d863 Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents: 1465
diff changeset
    75
    uint32_t rx_buffer_offset; /**< Offset in receive buffer. */
2a1106b1d863 Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents: 1465
diff changeset
    76
    uint32_t rx_expected_packet_no; /**< Expected receive packet number. */
2a1106b1d863 Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents: 1465
diff changeset
    77
    uint32_t rx_last_packet; /**< Current packet is the last to receive. */
2a1106b1d863 Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents: 1465
diff changeset
    78
    uint8_t *rx_filename; /**< Name of the file to receive. */
2a1106b1d863 Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents: 1465
diff changeset
    79
    uint32_t rx_filename_len; /**< Length of the receive file name. */
1335
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
};
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
/*****************************************************************************/
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
2498
9cdd7669dc0b Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents: 1901
diff changeset
    84
void ec_fsm_foe_init(ec_fsm_foe_t *);
1335
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
void ec_fsm_foe_clear(ec_fsm_foe_t *);
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
2498
9cdd7669dc0b Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents: 1901
diff changeset
    87
int ec_fsm_foe_exec(ec_fsm_foe_t *, ec_datagram_t *);
9cdd7669dc0b Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents: 1901
diff changeset
    88
int ec_fsm_foe_success(const ec_fsm_foe_t *);
1335
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
void ec_fsm_foe_transfer(ec_fsm_foe_t *, ec_slave_t *, ec_foe_request_t *);
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
/*****************************************************************************/
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
09c6fce1ae45 merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
#endif