master/fsm_coe.h
author Florian Pose <fp@igh-essen.com>
Wed, 13 Jan 2010 00:04:47 +0100
branchstable-1.4
changeset 1769 5c317e78a5ef
parent 1696 c9bfe98e00d5
permissions -rw-r--r--
merge
436
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
1685
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1038
diff changeset
     5
 *  Copyright (C) 2006-2008  Florian Pose, Ingenieurgemeinschaft IgH
436
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *  This file is part of the IgH EtherCAT Master.
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
1685
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1038
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it and/or
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1038
diff changeset
    10
 *  modify it under the terms of the GNU General Public License version 2, as
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1038
diff changeset
    11
 *  published by the Free Software Foundation.
436
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
 *
1685
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1038
diff changeset
    13
 *  The IgH EtherCAT Master is distributed in the hope that it will be useful,
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1038
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1038
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1038
diff changeset
    16
 *  Public License for more details.
436
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
 *
1685
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1038
diff changeset
    18
 *  You should have received a copy of the GNU General Public License along
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1038
diff changeset
    19
 *  with the IgH EtherCAT Master; if not, write to the Free Software
436
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
 *
1685
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1038
diff changeset
    22
 *  Using the EtherCAT technology and brand is permitted in compliance with
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1038
diff changeset
    23
 *  the industrial property and similar rights of Beckhoff Automation GmbH.
436
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
 *
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
 *****************************************************************************/
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
/**
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
   \file
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
   EtherCAT CoE state machines.
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
*/
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
/*****************************************************************************/
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
883
4963e22a267a Equalized defines against duplicated header inclusion.
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
    34
#ifndef __EC_FSM_COE_H__
4963e22a267a Equalized defines against duplicated header inclusion.
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
    35
#define __EC_FSM_COE_H__
436
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
#include "globals.h"
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
#include "../include/ecrt.h"
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
#include "datagram.h"
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
#include "slave.h"
847
92266462d411 Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 825
diff changeset
    41
#include "sdo.h"
92266462d411 Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 825
diff changeset
    42
#include "sdo_request.h"
436
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
/*****************************************************************************/
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
typedef struct ec_fsm_coe ec_fsm_coe_t; /**< \see ec_fsm_coe */
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
1686
e206f4485f60 Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1685
diff changeset
    48
/** Finite state machines for the CANopen over EtherCAT protocol.
825
3771f5a0ed90 CoE state machines raising error, if the slave does not support CoE.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    49
 */
3771f5a0ed90 CoE state machines raising error, if the slave does not support CoE.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    50
struct ec_fsm_coe {
436
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
    ec_slave_t *slave; /**< slave the FSM runs on */
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
    ec_datagram_t *datagram; /**< datagram used in the state machine */
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 436
diff changeset
    53
    unsigned int retries; /**< retries upon datagram timeout */
436
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
    void (*state)(ec_fsm_coe_t *); /**< CoE state function */
1038
7ca4103ba170 Use jiffies instead of cycles in CoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 883
diff changeset
    56
    unsigned long jiffies_start; /**< CoE timestamp. */
1686
e206f4485f60 Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1685
diff changeset
    57
    ec_sdo_t *sdo; /**< current SDO */
436
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
    uint8_t subindex; /**< current subindex */
1686
e206f4485f60 Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1685
diff changeset
    59
    ec_sdo_request_t *request; /**< SDO request */
1696
c9bfe98e00d5 merge -c1622 branches/1.4-foe: Fixed seg_size parameter when processing an CoE Upload Segment Response.
Florian Pose <fp@igh-essen.com>
parents: 1686
diff changeset
    60
    uint32_t complete_size; /**< Used when segmenting. */
436
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
    uint8_t toggle; /**< toggle bit for segment commands */
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
};
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
/*****************************************************************************/
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
void ec_fsm_coe_init(ec_fsm_coe_t *, ec_datagram_t *);
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
void ec_fsm_coe_clear(ec_fsm_coe_t *);
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
void ec_fsm_coe_dictionary(ec_fsm_coe_t *, ec_slave_t *);
859
233e32f428e1 Replaced ec_fsm_coe_\(upload\|download\)() with ec_fsm_coe_transfer();
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
    70
void ec_fsm_coe_transfer(ec_fsm_coe_t *, ec_slave_t *, ec_sdo_request_t *);
436
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
int ec_fsm_coe_exec(ec_fsm_coe_t *);
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
int ec_fsm_coe_success(ec_fsm_coe_t *);
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
/*****************************************************************************/
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
#endif