master/fsm_master.c
author Florian Pose <fp@igh-essen.com>
Thu, 02 Oct 2008 09:56:39 +0000
branchstable-1.3
changeset 1760 036f19bde00b
parent 1746 72e7507b3f1b
permissions -rw-r--r--
Fixed lsec for terminals that do not support getting the terminal width.
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 *  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *  This file is part of the IgH EtherCAT Master.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
 *  and/or modify it under the terms of the GNU General Public License
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
 *  as published by the Free Software Foundation; either version 2 of the
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
 *  License, or (at your option) any later version.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
 *
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
 *  The IgH EtherCAT Master is distributed in the hope that it will be
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
 *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
 *  GNU General Public License for more details.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
 *
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
 *  You should have received a copy of the GNU General Public License
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
 *  along with the IgH EtherCAT Master; if not, write to the Free Software
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
 *
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
 *  The right to use EtherCAT Technology is granted and comes free of
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
 *  charge under condition of compatibility of product made by
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
 *  Licensee. People intending to distribute/sell products based on the
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
 *  code, have to sign an agreement to guarantee that products using
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
 *  software based on IgH EtherCAT master stay compatible with the actual
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 *  EtherCAT specification (which are released themselves as an open
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
 *  standard) as the (only) precondition to have the right to use EtherCAT
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
 *  Technology, IP and trade marks.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
 *
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
 *****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
/**
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
   \file
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
   EtherCAT finite state machines.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
*/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
#include "globals.h"
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
#include "master.h"
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
#include "mailbox.h"
1745
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
    44
#ifdef EC_EOE
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
    45
#include "ethernet.h"
1745
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
    46
#endif
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
#include "fsm_master.h"
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
void ec_fsm_master_state_start(ec_fsm_master_t *);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
void ec_fsm_master_state_broadcast(ec_fsm_master_t *);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
void ec_fsm_master_state_read_states(ec_fsm_master_t *);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
void ec_fsm_master_state_acknowledge(ec_fsm_master_t *);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
void ec_fsm_master_state_validate_vendor(ec_fsm_master_t *);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
void ec_fsm_master_state_validate_product(ec_fsm_master_t *);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
void ec_fsm_master_state_rewrite_addresses(ec_fsm_master_t *);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
void ec_fsm_master_state_configure_slave(ec_fsm_master_t *);
1745
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
    59
void ec_fsm_master_state_clear_addresses(ec_fsm_master_t *);
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
void ec_fsm_master_state_scan_slaves(ec_fsm_master_t *);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
void ec_fsm_master_state_write_eeprom(ec_fsm_master_t *);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
void ec_fsm_master_state_sdodict(ec_fsm_master_t *);
1746
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
    63
void ec_fsm_master_state_pdomap(ec_fsm_master_t *);
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
void ec_fsm_master_state_sdo_request(ec_fsm_master_t *);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
void ec_fsm_master_state_end(ec_fsm_master_t *);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
void ec_fsm_master_state_error(ec_fsm_master_t *);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
/**
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
   Constructor.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
*/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
void ec_fsm_master_init(ec_fsm_master_t *fsm, /**< master state machine */
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
        ec_master_t *master, /**< EtherCAT master */
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
        ec_datagram_t *datagram /**< datagram object to use */
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
        )
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
{
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
    fsm->master = master;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
    fsm->datagram = datagram;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
    fsm->state = ec_fsm_master_state_start;
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
    82
    fsm->idle = 0;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
    fsm->slaves_responding = 0;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
    fsm->topology_change_pending = 0;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
    fsm->slave_states = EC_SLAVE_STATE_UNKNOWN;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
    fsm->validate = 0;
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
    87
    fsm->tainted = 0;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
    // init sub-state-machines
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
    ec_fsm_slave_init(&fsm->fsm_slave, fsm->datagram);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
    ec_fsm_sii_init(&fsm->fsm_sii, fsm->datagram);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
    ec_fsm_change_init(&fsm->fsm_change, fsm->datagram);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
    ec_fsm_coe_init(&fsm->fsm_coe, fsm->datagram);
1746
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
    94
    ec_fsm_coe_map_init(&fsm->fsm_coe_map, &fsm->fsm_coe);
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
/**
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
   Destructor.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
*/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
void ec_fsm_master_clear(ec_fsm_master_t *fsm /**< master state machine */)
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
{
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
    // clear sub-state machines
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
    ec_fsm_slave_clear(&fsm->fsm_slave);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
    ec_fsm_sii_clear(&fsm->fsm_sii);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
    ec_fsm_change_clear(&fsm->fsm_change);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
    ec_fsm_coe_clear(&fsm->fsm_coe);
1746
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   110
    ec_fsm_coe_map_clear(&fsm->fsm_coe_map);
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
/**
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
   Executes the current state of the state machine.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
   If the state machine's datagram is not sent or received yet, the execution
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
   of the state machine is delayed to the next cycle.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
   \return false, if state machine has terminated
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
*/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
int ec_fsm_master_exec(ec_fsm_master_t *fsm /**< master state machine */)
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
{
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
    if (fsm->datagram->state == EC_DATAGRAM_SENT
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
        || fsm->datagram->state == EC_DATAGRAM_QUEUED) {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
        // datagram was not sent or received yet.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
        return ec_fsm_master_running(fsm);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
    fsm->state(fsm);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
    return ec_fsm_master_running(fsm);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
/**
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   137
 * \return false, if state machine has terminated
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   138
 */
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   139
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   140
int ec_fsm_master_running(
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   141
        const ec_fsm_master_t *fsm /**< master state machine */
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   142
        )
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
{
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
    return fsm->state != ec_fsm_master_state_end
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
        && fsm->state != ec_fsm_master_state_error;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
/**
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   151
 * \return true, if the state machine is in an idle phase
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   152
 */
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   153
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   154
int ec_fsm_master_idle(
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   155
        const ec_fsm_master_t *fsm /**< master state machine */
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   156
        )
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   157
{
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   158
    return fsm->idle;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
/******************************************************************************
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   162
 *  master state machine
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
 *****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
/**
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
   Master state: START.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
   Starts with getting slave count and slave states.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
*/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
void ec_fsm_master_state_start(ec_fsm_master_t *fsm)
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
{
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   172
    fsm->idle = 1;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
    ec_datagram_brd(fsm->datagram, 0x0130, 2);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
    fsm->state = ec_fsm_master_state_broadcast;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
/**
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
   Master state: BROADCAST.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
   Processes the broadcast read slave count and slaves states.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
*/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
void ec_fsm_master_state_broadcast(ec_fsm_master_t *fsm /**< master state machine */)
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
{
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
    ec_datagram_t *datagram = fsm->datagram;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
    unsigned int i;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
    ec_slave_t *slave;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
    ec_master_t *master = fsm->master;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   191
    if (datagram->state == EC_DATAGRAM_TIMED_OUT)
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   192
        return; // always retry
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   193
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   194
    if (datagram->state != EC_DATAGRAM_RECEIVED) { // link is down
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   195
        fsm->slaves_responding = 0;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
        list_for_each_entry(slave, &master->slaves, list) {
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   197
            ec_slave_set_online_state(slave, EC_SLAVE_OFFLINE);
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
        }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
        fsm->state = ec_fsm_master_state_error;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
        return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
    // bus topology change?
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
    if (datagram->working_counter != fsm->slaves_responding) {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
        fsm->topology_change_pending = 1;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
        fsm->slaves_responding = datagram->working_counter;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   208
        EC_INFO("%i slave%s responding.\n",
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   209
                fsm->slaves_responding,
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
                fsm->slaves_responding == 1 ? "" : "s");
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   211
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   212
        if (master->mode == EC_MASTER_MODE_OPERATION) {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   213
            if (fsm->slaves_responding == master->slave_count) {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
                fsm->validate = 1; // start validation later
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   215
            }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   216
            else {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   217
                EC_WARN("Invalid slave count. Bus in tainted state.\n");
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   218
                fsm->tainted = 1;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   219
            }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
        }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   221
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   222
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   223
    // slave states changed?
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   224
    if (EC_READ_U8(datagram->data) != fsm->slave_states) {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   225
        char states[EC_STATE_STRING_SIZE];
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   226
        fsm->slave_states = EC_READ_U8(datagram->data);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   227
        ec_state_string(fsm->slave_states, states);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   228
        EC_INFO("Slave states: %s.\n", states);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   230
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   231
    if (fsm->topology_change_pending) {
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   232
        down(&master->scan_sem);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   233
        if (!master->allow_scan) {
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   234
            up(&master->scan_sem);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   235
        }
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   236
        else {
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   237
            master->scan_state = EC_REQUEST_IN_PROGRESS;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   238
            up(&master->scan_sem);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   239
            
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   240
            // topology change when scan is allowed:
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   241
            // clear all slaves and scan the bus
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   242
            fsm->topology_change_pending = 0;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   243
            fsm->tainted = 0;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   244
            fsm->idle = 0;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   245
            fsm->scan_jiffies = jiffies;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   246
1745
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   247
#ifdef EC_EOE
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   248
            ec_master_eoe_stop(master);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   249
            ec_master_clear_eoe_handlers(master);
1745
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   250
#endif
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   251
            ec_master_destroy_slaves(master);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   252
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   253
            master->slave_count = datagram->working_counter;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   254
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   255
            if (!master->slave_count) {
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   256
                // no slaves present -> finish state machine.
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   257
                master->scan_state = EC_REQUEST_COMPLETE;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   258
                wake_up_interruptible(&master->scan_queue);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   259
                fsm->state = ec_fsm_master_state_end;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   260
                return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   261
            }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   262
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   263
            // init slaves
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   264
            for (i = 0; i < master->slave_count; i++) {
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   265
                if (!(slave = (ec_slave_t *) kmalloc(sizeof(ec_slave_t),
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   266
                                GFP_ATOMIC))) {
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   267
                    EC_ERR("Failed to allocate slave %i!\n", i);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   268
                    ec_master_destroy_slaves(master);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   269
                    master->scan_state = EC_REQUEST_FAILURE;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   270
                    wake_up_interruptible(&master->scan_queue);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   271
                    fsm->state = ec_fsm_master_state_error;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   272
                    return;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   273
                }
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   274
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   275
                if (ec_slave_init(slave, master, i, i + 1)) {
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   276
                    // freeing of "slave" already done
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   277
                    ec_master_destroy_slaves(master);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   278
                    master->scan_state = EC_REQUEST_FAILURE;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   279
                    wake_up_interruptible(&master->scan_queue);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   280
                    fsm->state = ec_fsm_master_state_error;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   281
                    return;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   282
                }
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   283
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   284
                list_add_tail(&slave->list, &master->slaves);
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   285
            }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   286
1745
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   287
            if (master->debug_level)
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   288
                EC_DBG("Clearing station addresses...\n");
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   289
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   290
            ec_datagram_bwr(datagram, 0x0010, 2);
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   291
            EC_WRITE_U16(datagram->data, 0x0000);
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   292
            fsm->retries = EC_FSM_RETRIES;
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   293
            fsm->state = ec_fsm_master_state_clear_addresses;
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   294
            return;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   295
        }
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   296
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   297
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   298
    // fetch state from each slave
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   299
    fsm->slave = list_entry(master->slaves.next, ec_slave_t, list);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   300
    ec_datagram_nprd(fsm->datagram, fsm->slave->station_address, 0x0130, 2);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   301
    fsm->retries = EC_FSM_RETRIES;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   302
    fsm->state = ec_fsm_master_state_read_states;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   303
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   304
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   305
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   306
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   307
/**
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   308
 * Check for pending EEPROM write requests and process one.
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   309
 * \return non-zero, if an EEPROM write request is processed.
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   310
 */
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   311
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   312
int ec_fsm_master_action_process_eeprom(
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   313
        ec_fsm_master_t *fsm /**< master state machine */
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   314
        )
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
{
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
    ec_master_t *master = fsm->master;
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   317
    ec_eeprom_write_request_t *request;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   318
    ec_slave_t *slave;
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   319
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   320
    // search the first request to be processed
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   321
    while (1) {
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   322
        down(&master->eeprom_sem);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   323
        if (list_empty(&master->eeprom_requests)) {
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   324
            up(&master->eeprom_sem);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   325
            break;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   326
        }
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   327
        // get first request
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   328
        request = list_entry(master->eeprom_requests.next,
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   329
                ec_eeprom_write_request_t, list);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   330
        list_del_init(&request->list); // dequeue
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   331
        request->state = EC_REQUEST_IN_PROGRESS;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   332
        up(&master->eeprom_sem);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   333
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   334
        slave = request->slave;
1746
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   335
        if (slave->online_state == EC_SLAVE_OFFLINE) {
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   336
            EC_ERR("Discarding EEPROM data, slave %i offline.\n",
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   337
                    slave->ring_position);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   338
            request->state = EC_REQUEST_FAILURE;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   339
            wake_up(&master->eeprom_queue);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   340
            continue;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   341
        }
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   342
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   343
        // found pending EEPROM write operation. execute it!
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   344
        if (master->debug_level)
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   345
            EC_DBG("Writing EEPROM data to slave %i...\n",
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   346
                    slave->ring_position);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   347
        fsm->eeprom_request = request;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   348
        fsm->eeprom_index = 0;
1746
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   349
        ec_fsm_sii_write(&fsm->fsm_sii, request->slave, request->word_offset,
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   350
                request->data, EC_FSM_SII_NODE);
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   351
        fsm->state = ec_fsm_master_state_write_eeprom;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   352
        fsm->state(fsm); // execute immediately
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   353
        return 1;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   354
    }
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   355
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   356
    return 0;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   357
}
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   358
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   359
/*****************************************************************************/
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   360
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   361
/**
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   362
 * Check for pending SDO requests and process one.
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   363
 * \return non-zero, if an SDO request is processed.
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   364
 */
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   365
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   366
int ec_fsm_master_action_process_sdo(
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   367
        ec_fsm_master_t *fsm /**< master state machine */
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   368
        )
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   369
{
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   370
    ec_master_t *master = fsm->master;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   371
    ec_sdo_request_t *request;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   372
    ec_slave_t *slave;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   373
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   374
    // search the first request to be processed
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   375
    while (1) {
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   376
        down(&master->sdo_sem);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   377
        if (list_empty(&master->sdo_requests)) {
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   378
            up(&master->sdo_sem);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   379
            break;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   380
        }
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   381
        // get first request
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   382
        request =
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   383
            list_entry(master->sdo_requests.next, ec_sdo_request_t, list);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   384
        list_del_init(&request->list); // dequeue
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   385
        request->state = EC_REQUEST_IN_PROGRESS;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   386
        up(&master->sdo_sem);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   387
1746
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   388
        slave = request->entry->sdo->slave;
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   389
        if (slave->current_state == EC_SLAVE_STATE_INIT ||
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   390
                slave->online_state == EC_SLAVE_OFFLINE ||
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   391
                slave->error_flag) {
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   392
            EC_ERR("Discarding SDO request, slave %i not ready.\n",
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   393
                    slave->ring_position);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   394
            request->state = EC_REQUEST_FAILURE;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   395
            wake_up(&master->sdo_queue);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   396
            continue;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   397
        }
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   398
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   399
        // found pending SDO request. execute it!
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   400
        if (master->debug_level)
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   401
            EC_DBG("Processing SDO request for slave %i...\n",
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   402
                    slave->ring_position);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   403
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   404
        // start uploading SDO
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   405
        fsm->idle = 0;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   406
        fsm->slave = slave;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   407
        fsm->sdo_request = request;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   408
        fsm->state = ec_fsm_master_state_sdo_request;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   409
        ec_fsm_coe_upload(&fsm->fsm_coe, slave, fsm->sdo_request);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   410
        ec_fsm_coe_exec(&fsm->fsm_coe); // execute immediately
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   411
        return 1;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   412
    }
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   413
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   414
    return 0;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   415
}
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   416
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   417
/*****************************************************************************/
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   418
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   419
/**
1746
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   420
 * Check for slaves that are not configured and configure them.
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   421
 */
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   422
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   423
int ec_fsm_master_action_configure(
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   424
        ec_fsm_master_t *fsm /**< master state machine */
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   425
        )
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   426
{
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   427
    ec_slave_t *slave;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   428
    ec_master_t *master = fsm->master;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   429
    char old_state[EC_STATE_STRING_SIZE], new_state[EC_STATE_STRING_SIZE];
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   430
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   431
    // check if any slaves are not in the state, they're supposed to be
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   432
    // FIXME do not check all slaves in every cycle...
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   433
    list_for_each_entry(slave, &master->slaves, list) {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   434
        if (slave->error_flag
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   435
                || slave->online_state == EC_SLAVE_OFFLINE
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   436
                || slave->requested_state == EC_SLAVE_STATE_UNKNOWN
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   437
                || (slave->current_state == slave->requested_state
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   438
                    && slave->self_configured)) continue;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   439
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   440
        if (master->debug_level) {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   441
            ec_state_string(slave->current_state, old_state);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   442
            if (slave->current_state != slave->requested_state) {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   443
                ec_state_string(slave->requested_state, new_state);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   444
                EC_DBG("Changing state of slave %i (%s -> %s).\n",
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   445
                        slave->ring_position, old_state, new_state);
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   446
            }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   447
            else if (!slave->self_configured) {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   448
                EC_DBG("Reconfiguring slave %i (%s).\n",
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   449
                        slave->ring_position, old_state);
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   450
            }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   451
        }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   452
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   453
        fsm->idle = 0;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   454
        fsm->slave = slave;
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   455
        fsm->state = ec_fsm_master_state_configure_slave;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   456
        ec_fsm_slave_start_conf(&fsm->fsm_slave, slave);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   457
        ec_fsm_slave_exec(&fsm->fsm_slave); // execute immediately
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   458
        return 1;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   459
    }
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   460
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   461
    if (fsm->config_error)
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   462
        master->config_state = EC_REQUEST_FAILURE;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   463
    else
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   464
        master->config_state = EC_REQUEST_COMPLETE;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   465
    wake_up_interruptible(&master->config_queue);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   466
    return 0;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   467
}
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   468
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   469
/*****************************************************************************/
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   470
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   471
/**
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   472
   Master action: PROC_STATES.
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   473
   Processes the slave states.
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   474
*/
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   475
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   476
void ec_fsm_master_action_process_states(ec_fsm_master_t *fsm
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   477
                                         /**< master state machine */
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   478
                                         )
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   479
{
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   480
    ec_master_t *master = fsm->master;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   481
    ec_slave_t *slave;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   482
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   483
    down(&master->config_sem);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   484
    if (!master->allow_config) {
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   485
        up(&master->config_sem);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   486
    }
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   487
    else {
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   488
        master->config_state = EC_REQUEST_IN_PROGRESS;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   489
        fsm->config_error = 0;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   490
        up(&master->config_sem);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   491
        
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   492
        // check for pending slave configurations
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   493
        if (ec_fsm_master_action_configure(fsm))
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   494
            return;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   495
    }
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   496
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   497
    // Check for a pending SDO request
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   498
    if (ec_fsm_master_action_process_sdo(fsm))
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   499
        return;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   500
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   501
    if (master->mode == EC_MASTER_MODE_IDLE) {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   502
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   503
        // check, if slaves have an SDO dictionary to read out.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   504
        list_for_each_entry(slave, &master->slaves, list) {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   505
            if (!(slave->sii_mailbox_protocols & EC_MBOX_COE)
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   506
                || slave->sdo_dictionary_fetched
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   507
                || slave->current_state == EC_SLAVE_STATE_INIT
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   508
                || jiffies - slave->jiffies_preop < EC_WAIT_SDO_DICT * HZ
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   509
                || slave->online_state == EC_SLAVE_OFFLINE
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   510
                || slave->error_flag) continue;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   511
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   512
            if (master->debug_level) {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   513
                EC_DBG("Fetching SDO dictionary from slave %i.\n",
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   514
                       slave->ring_position);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   515
            }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   516
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   517
            slave->sdo_dictionary_fetched = 1;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   518
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   519
            // start fetching SDO dictionary
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   520
            fsm->idle = 0;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   521
            fsm->slave = slave;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   522
            fsm->state = ec_fsm_master_state_sdodict;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   523
            ec_fsm_coe_dictionary(&fsm->fsm_coe, slave);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   524
            ec_fsm_coe_exec(&fsm->fsm_coe); // execute immediately
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   525
            return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   526
        }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   527
1746
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   528
        // check, if slaves have their PDO mapping to be read.
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   529
        list_for_each_entry(slave, &master->slaves, list) {
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   530
            if (!(slave->sii_mailbox_protocols & EC_MBOX_COE)
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   531
                || slave->pdo_mapping_fetched
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   532
                || !slave->sdo_dictionary_fetched
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   533
                || slave->current_state == EC_SLAVE_STATE_INIT
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   534
                || slave->online_state == EC_SLAVE_OFFLINE) continue;
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   535
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   536
            if (master->debug_level) {
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   537
                EC_DBG("Fetching PDO mapping from slave %i via CoE.\n",
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   538
                       slave->ring_position);
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   539
            }
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   540
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   541
            slave->pdo_mapping_fetched = 1;
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   542
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   543
            // start fetching PDO mapping
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   544
            fsm->idle = 0;
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   545
            fsm->state = ec_fsm_master_state_pdomap;
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   546
            ec_fsm_coe_map_start(&fsm->fsm_coe_map, slave);
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   547
            ec_fsm_coe_map_exec(&fsm->fsm_coe_map); // execute immediately
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   548
            return;
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   549
        }
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   550
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   551
        // check for pending EEPROM write operations.
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   552
        if (ec_fsm_master_action_process_eeprom(fsm))
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   553
            return; // EEPROM write request found
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   554
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   555
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   556
    fsm->state = ec_fsm_master_state_end;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   557
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   558
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   559
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   560
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   561
/**
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   562
   Master action: Get state of next slave.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   563
*/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   564
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   565
void ec_fsm_master_action_next_slave_state(ec_fsm_master_t *fsm
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   566
                                           /**< master state machine */)
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   567
{
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   568
    ec_master_t *master = fsm->master;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   569
    ec_slave_t *slave = fsm->slave;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   570
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   571
    // is there another slave to query?
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   572
    if (slave->list.next != &master->slaves) {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   573
        // process next slave
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   574
        fsm->idle = 1;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   575
        fsm->slave = list_entry(slave->list.next, ec_slave_t, list);
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   576
        ec_datagram_nprd(fsm->datagram, fsm->slave->station_address,
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   577
                         0x0130, 2);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   578
        fsm->retries = EC_FSM_RETRIES;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   579
        fsm->state = ec_fsm_master_state_read_states;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   580
        return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   581
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   582
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   583
    // all slave states read
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   584
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   585
    // check, if a bus validation has to be done
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   586
    if (fsm->validate) {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   587
        fsm->validate = 0;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   588
        list_for_each_entry(slave, &master->slaves, list) {
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   589
            if (slave->online_state == EC_SLAVE_ONLINE) continue;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   590
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   591
            // At least one slave is offline. validate!
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   592
            EC_INFO("Validating bus.\n");
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   593
            fsm->idle = 0;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   594
            fsm->slave = list_entry(master->slaves.next, ec_slave_t, list);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   595
            fsm->state = ec_fsm_master_state_validate_vendor;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   596
            ec_fsm_sii_read(&fsm->fsm_sii, slave, 0x0008, EC_FSM_SII_POSITION);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   597
            ec_fsm_sii_exec(&fsm->fsm_sii); // execute immediately
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   598
            return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   599
        }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   600
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   601
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   602
    ec_fsm_master_action_process_states(fsm);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   603
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   604
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   605
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   606
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   607
/**
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   608
   Master state: READ STATES.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   609
   Fetches the AL- and online state of a slave.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   610
*/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   611
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   612
void ec_fsm_master_state_read_states(ec_fsm_master_t *fsm /**< master state machine */)
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   613
{
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   614
    ec_slave_t *slave = fsm->slave;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   615
    ec_datagram_t *datagram = fsm->datagram;
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   616
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   617
    if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   618
        return;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   619
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   620
    if (datagram->state != EC_DATAGRAM_RECEIVED) {
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   621
        EC_ERR("Failed to receive AL state datagram for slave %i"
1745
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   622
                " (datagram state %i)\n",
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   623
                slave->ring_position, datagram->state);
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   624
        fsm->state = ec_fsm_master_state_error;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   625
        return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   626
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   627
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   628
    // did the slave not respond to its station address?
1745
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   629
    if (datagram->working_counter == 0) {
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   630
        ec_slave_set_online_state(slave, EC_SLAVE_OFFLINE);
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   631
        ec_fsm_master_action_next_slave_state(fsm);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   632
        return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   633
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   634
1745
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   635
    // FIXME what to to on multiple response?
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   636
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   637
    // slave responded
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   638
    ec_slave_set_state(slave, EC_READ_U8(datagram->data)); // set app state first
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   639
    ec_slave_set_online_state(slave, EC_SLAVE_ONLINE);
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   640
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   641
    // check, if new slave state has to be acknowledged
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   642
    if (slave->current_state & EC_SLAVE_STATE_ACK_ERR && !slave->error_flag) {
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   643
        fsm->idle = 0;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   644
        fsm->state = ec_fsm_master_state_acknowledge;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   645
        ec_fsm_change_ack(&fsm->fsm_change, slave);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   646
        ec_fsm_change_exec(&fsm->fsm_change);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   647
        return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   648
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   649
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   650
    ec_fsm_master_action_next_slave_state(fsm);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   651
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   652
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   653
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   654
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   655
/**
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   656
   Master state: ACKNOWLEDGE
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   657
*/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   658
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   659
void ec_fsm_master_state_acknowledge(ec_fsm_master_t *fsm /**< master state machine */)
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   660
{
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   661
    ec_slave_t *slave = fsm->slave;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   662
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   663
    if (ec_fsm_change_exec(&fsm->fsm_change)) return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   664
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   665
    if (!ec_fsm_change_success(&fsm->fsm_change)) {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   666
        fsm->slave->error_flag = 1;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   667
        EC_ERR("Failed to acknowledge state change on slave %i.\n",
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   668
               slave->ring_position);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   669
        fsm->state = ec_fsm_master_state_error;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   670
        return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   671
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   672
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   673
    ec_fsm_master_action_next_slave_state(fsm);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   674
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   675
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   676
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   677
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   678
/**
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   679
   Master state: VALIDATE_VENDOR.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   680
   Validates the vendor ID of a slave.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   681
*/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   682
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   683
void ec_fsm_master_state_validate_vendor(ec_fsm_master_t *fsm /**< master state machine */)
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   684
{
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   685
    ec_slave_t *slave = fsm->slave;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   686
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   687
    if (ec_fsm_sii_exec(&fsm->fsm_sii)) return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   688
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   689
    if (!ec_fsm_sii_success(&fsm->fsm_sii)) {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   690
        fsm->slave->error_flag = 1;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   691
        EC_ERR("Failed to validate vendor ID of slave %i.\n",
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   692
               slave->ring_position);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   693
        fsm->state = ec_fsm_master_state_error;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   694
        return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   695
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   696
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   697
    if (EC_READ_U32(fsm->fsm_sii.value) != slave->sii_vendor_id) {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   698
        EC_ERR("Slave %i has an invalid vendor ID!\n", slave->ring_position);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   699
        fsm->state = ec_fsm_master_state_error;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   700
        return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   701
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   702
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   703
    // vendor ID is ok. check product code.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   704
    fsm->state = ec_fsm_master_state_validate_product;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   705
    ec_fsm_sii_read(&fsm->fsm_sii, slave, 0x000A, EC_FSM_SII_POSITION);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   706
    ec_fsm_sii_exec(&fsm->fsm_sii); // execute immediately
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   707
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   708
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   709
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   710
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   711
/**
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   712
   Master action: ADDRESS.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   713
   Looks for slave, that have lost their configuration and writes
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   714
   their station address, so that they can be reconfigured later.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   715
*/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   716
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   717
void ec_fsm_master_action_addresses(ec_fsm_master_t *fsm /**< master state machine */)
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   718
{
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   719
    ec_datagram_t *datagram = fsm->datagram;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   720
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   721
    while (fsm->slave->online_state == EC_SLAVE_ONLINE) {
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   722
        if (fsm->slave->list.next == &fsm->master->slaves) { // last slave?
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   723
            fsm->state = ec_fsm_master_state_end;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   724
            return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   725
        }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   726
        // check next slave
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   727
        fsm->slave = list_entry(fsm->slave->list.next, ec_slave_t, list);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   728
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   729
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   730
    if (fsm->master->debug_level)
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   731
        EC_DBG("Reinitializing slave %i.\n", fsm->slave->ring_position);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   732
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   733
    // write station address
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   734
    ec_datagram_apwr(datagram, fsm->slave->ring_position, 0x0010, 2);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   735
    EC_WRITE_U16(datagram->data, fsm->slave->station_address);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   736
    fsm->retries = EC_FSM_RETRIES;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   737
    fsm->state = ec_fsm_master_state_rewrite_addresses;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   738
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   740
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   741
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   742
/**
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   743
   Master state: VALIDATE_PRODUCT.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   744
   Validates the product ID of a slave.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   745
*/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   746
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   747
void ec_fsm_master_state_validate_product(ec_fsm_master_t *fsm /**< master state machine */)
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   748
{
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   749
    ec_slave_t *slave = fsm->slave;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   750
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   751
    if (ec_fsm_sii_exec(&fsm->fsm_sii)) return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   752
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   753
    if (!ec_fsm_sii_success(&fsm->fsm_sii)) {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   754
        fsm->slave->error_flag = 1;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   755
        EC_ERR("Failed to validate product code of slave %i.\n",
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   756
               slave->ring_position);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   757
        fsm->state = ec_fsm_master_state_error;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   758
        return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   759
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   760
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   761
    if (EC_READ_U32(fsm->fsm_sii.value) != slave->sii_product_code) {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   762
        EC_ERR("Slave %i: invalid product code!\n", slave->ring_position);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   763
        EC_ERR("expected 0x%08X, got 0x%08X.\n", slave->sii_product_code,
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   764
               EC_READ_U32(fsm->fsm_sii.value));
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   765
        fsm->state = ec_fsm_master_state_error;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   766
        return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   767
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   768
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   769
    // have all states been validated?
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   770
    if (slave->list.next == &fsm->master->slaves) {
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   771
        fsm->topology_change_pending = 0;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   772
        fsm->tainted = 0;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   773
        fsm->slave = list_entry(fsm->master->slaves.next, ec_slave_t, list);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   774
        // start writing addresses to offline slaves
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   775
        ec_fsm_master_action_addresses(fsm);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   776
        return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   777
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   778
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   779
    // validate next slave
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   780
    fsm->slave = list_entry(fsm->slave->list.next, ec_slave_t, list);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   781
    fsm->state = ec_fsm_master_state_validate_vendor;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   782
    ec_fsm_sii_read(&fsm->fsm_sii, slave, 0x0008, EC_FSM_SII_POSITION);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   783
    ec_fsm_sii_exec(&fsm->fsm_sii); // execute immediately
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   784
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   785
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   786
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   787
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   788
/**
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   789
   Master state: REWRITE ADDRESS.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   790
   Checks, if the new station address has been written to the slave.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   791
*/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   792
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   793
void ec_fsm_master_state_rewrite_addresses(ec_fsm_master_t *fsm
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   794
                                     /**< master state machine */
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   795
                                     )
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   796
{
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   797
    ec_slave_t *slave = fsm->slave;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   798
    ec_datagram_t *datagram = fsm->datagram;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   799
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   800
    if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   801
        return;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   802
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   803
    if (datagram->state != EC_DATAGRAM_RECEIVED) {
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   804
        EC_ERR("Failed to receive address datagram for slave %i"
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   805
                " (datagram state %i).\n",
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   806
                slave->ring_position, datagram->state);
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   807
        fsm->state = ec_fsm_master_state_error;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   808
        return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   809
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   810
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   811
    if (datagram->working_counter != 1) {
1745
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   812
        EC_ERR("Failed to write station address of slave %i: ",
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   813
               slave->ring_position);
1745
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   814
        ec_datagram_print_wc_error(datagram);
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   815
        fsm->state = ec_fsm_master_state_error;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   816
        return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   817
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   818
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   819
    if (fsm->slave->list.next == &fsm->master->slaves) { // last slave?
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   820
        fsm->state = ec_fsm_master_state_end;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   821
        return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   822
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   823
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   824
    // check next slave
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   825
    fsm->slave = list_entry(fsm->slave->list.next, ec_slave_t, list);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   826
    // Write new station address to slave
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   827
    ec_fsm_master_action_addresses(fsm);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   828
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   829
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   830
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   831
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   832
/**
1745
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   833
 * Master state: CLEAR ADDRESSES.
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   834
 */
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   835
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   836
void ec_fsm_master_state_clear_addresses(
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   837
        ec_fsm_master_t *fsm /**< master state machine */
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   838
        )
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   839
{
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   840
    ec_master_t *master = fsm->master;
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   841
    ec_datagram_t *datagram = fsm->datagram;
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   842
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   843
    if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   844
        return;
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   845
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   846
    if (datagram->state != EC_DATAGRAM_RECEIVED) {
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   847
        EC_ERR("Failed to receive address clearing datagram (state %i).\n",
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   848
                datagram->state);
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   849
        fsm->state = ec_fsm_master_state_error;
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   850
        return;
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   851
    }
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   852
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   853
    if (datagram->working_counter != master->slave_count) {
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   854
        EC_WARN("Failed to clear all station addresses: Cleared %u of %u",
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   855
                datagram->working_counter, master->slave_count);
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   856
    }
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   857
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   858
    EC_INFO("Scanning bus.\n");
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   859
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   860
    // begin scanning of slaves
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   861
    fsm->slave = list_entry(master->slaves.next, ec_slave_t, list);
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   862
    fsm->state = ec_fsm_master_state_scan_slaves;
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   863
    ec_fsm_slave_start_scan(&fsm->fsm_slave, fsm->slave);
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   864
    ec_fsm_slave_exec(&fsm->fsm_slave); // execute immediately
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   865
}
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   866
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   867
/*****************************************************************************/
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   868
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   869
/**
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   870
 * Master state: SCAN SLAVES.
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   871
 * Executes the sub-statemachine for the scanning of a slave.
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   872
 */
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   873
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   874
void ec_fsm_master_state_scan_slaves(
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   875
        ec_fsm_master_t *fsm /**< master state machine */
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   876
        )
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   877
{
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   878
    ec_master_t *master = fsm->master;
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   879
    ec_slave_t *slave = fsm->slave;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   880
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   881
    if (ec_fsm_slave_exec(&fsm->fsm_slave)) // execute slave state machine
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   882
        return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   883
1745
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   884
#ifdef EC_EOE
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   885
    if (slave->sii_mailbox_protocols & EC_MBOX_EOE) {
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   886
        // create EoE handler for this slave
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   887
        ec_eoe_t *eoe;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   888
        if (!(eoe = kmalloc(sizeof(ec_eoe_t), GFP_KERNEL))) {
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   889
            EC_ERR("Failed to allocate EoE handler memory for slave %u!\n",
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   890
                    slave->ring_position);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   891
        }
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   892
        else if (ec_eoe_init(eoe, slave)) {
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   893
            EC_ERR("Failed to init EoE handler for slave %u!\n",
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   894
                    slave->ring_position);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   895
            kfree(eoe);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   896
        }
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   897
        else {
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   898
            list_add_tail(&eoe->list, &master->eoe_handlers);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   899
        }
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   900
    }
1745
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   901
#endif
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   902
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   903
    // another slave to fetch?
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   904
    if (slave->list.next != &master->slaves) {
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   905
        fsm->slave = list_entry(slave->list.next, ec_slave_t, list);
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   906
        ec_fsm_slave_start_scan(&fsm->fsm_slave, fsm->slave);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   907
        ec_fsm_slave_exec(&fsm->fsm_slave); // execute immediately
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   908
        return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   909
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   910
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   911
    EC_INFO("Bus scanning completed in %u ms.\n",
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   912
            (u32) (jiffies - fsm->scan_jiffies) * 1000 / HZ);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   913
1745
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   914
#ifdef EC_EOE
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   915
    // check if EoE processing has to be started
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   916
    ec_master_eoe_start(master);
1745
07fd94c5119d MERGE -r908:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk (1.3.1 changes)
Florian Pose <fp@igh-essen.com>
parents: 1744
diff changeset
   917
#endif
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   918
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   919
    master->scan_state = EC_REQUEST_COMPLETE;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   920
    wake_up_interruptible(&master->scan_queue);
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   921
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   922
    fsm->state = ec_fsm_master_state_end;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   923
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   924
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   925
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   926
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   927
/**
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   928
   Master state: CONFIGURE SLAVES.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   929
   Starts configuring a slave.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   930
*/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   931
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   932
void ec_fsm_master_state_configure_slave(ec_fsm_master_t *fsm
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   933
                                   /**< master state machine */
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   934
                                   )
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   935
{
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   936
    if (ec_fsm_slave_exec(&fsm->fsm_slave)) // execute slave's state machine
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   937
        return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   938
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   939
    if (!ec_fsm_slave_success(&fsm->fsm_slave))
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   940
        fsm->config_error = 1;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   941
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   942
    // configure next slave, if necessary
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   943
    if (ec_fsm_master_action_configure(fsm))
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   944
        return;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   945
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   946
    fsm->state = ec_fsm_master_state_end;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   947
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   948
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   949
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   950
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   951
/**
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   952
   Master state: WRITE EEPROM.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   953
*/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   954
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   955
void ec_fsm_master_state_write_eeprom(
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   956
        ec_fsm_master_t *fsm /**< master state machine */)
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   957
{
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   958
    ec_master_t *master = fsm->master;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   959
    ec_eeprom_write_request_t *request = fsm->eeprom_request;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   960
    ec_slave_t *slave = request->slave;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   961
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   962
    if (ec_fsm_sii_exec(&fsm->fsm_sii)) return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   963
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   964
    if (!ec_fsm_sii_success(&fsm->fsm_sii)) {
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   965
        slave->error_flag = 1;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   966
        EC_ERR("Failed to write EEPROM data to slave %i.\n",
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   967
                slave->ring_position);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   968
        request->state = EC_REQUEST_FAILURE;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   969
        wake_up(&master->eeprom_queue);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   970
        fsm->state = ec_fsm_master_state_error;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   971
        return;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   972
    }
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   973
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   974
    fsm->eeprom_index++;
1746
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   975
    if (fsm->eeprom_index < request->word_size) {
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   976
        ec_fsm_sii_write(&fsm->fsm_sii, slave,
1746
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   977
                request->word_offset + fsm->eeprom_index,
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   978
                request->data + fsm->eeprom_index * 2,
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   979
                EC_FSM_SII_NODE);
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   980
        ec_fsm_sii_exec(&fsm->fsm_sii); // execute immediately
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   981
        return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   982
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   983
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   984
    // finished writing EEPROM
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   985
    if (master->debug_level)
1746
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   986
        EC_DBG("Finished writing %u words of EEPROM data to slave %u.\n",
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
   987
                request->word_size, slave->ring_position);
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   988
    request->state = EC_REQUEST_COMPLETE;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   989
    wake_up(&master->eeprom_queue);
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   990
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   991
    // TODO: Evaluate new EEPROM contents!
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   992
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   993
    // check for another EEPROM write request
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   994
    if (ec_fsm_master_action_process_eeprom(fsm))
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   995
        return; // processing another request
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   996
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
   997
    fsm->state = ec_fsm_master_state_end;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   998
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   999
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1000
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1001
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1002
/**
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1003
   Master state: SDODICT.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1004
*/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1005
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1006
void ec_fsm_master_state_sdodict(ec_fsm_master_t *fsm /**< master state machine */)
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1007
{
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1008
    ec_slave_t *slave = fsm->slave;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1009
    ec_master_t *master = fsm->master;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1010
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1011
    if (ec_fsm_coe_exec(&fsm->fsm_coe)) return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1012
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1013
    if (!ec_fsm_coe_success(&fsm->fsm_coe)) {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1014
        fsm->state = ec_fsm_master_state_error;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1015
        return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1016
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1017
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1018
    // SDO dictionary fetching finished
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1019
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1020
    if (master->debug_level) {
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1021
        unsigned int sdo_count, entry_count;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1022
        ec_slave_sdo_dict_info(slave, &sdo_count, &entry_count);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1023
        EC_DBG("Fetched %i SDOs and %i entries from slave %i.\n",
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1024
               sdo_count, entry_count, slave->ring_position);
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1025
    }
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1026
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1027
    fsm->state = ec_fsm_master_state_end;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1028
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1029
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1030
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1031
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1032
/**
1746
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
  1033
 * Scan the PDO mapping of a slave.
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
  1034
 */
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
  1035
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
  1036
void ec_fsm_master_state_pdomap(
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
  1037
        ec_fsm_master_t *fsm /**< master state machine */
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
  1038
        )
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
  1039
{
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
  1040
    if (ec_fsm_coe_map_exec(&fsm->fsm_coe_map)) return;
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
  1041
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
  1042
    if (!ec_fsm_coe_map_success(&fsm->fsm_coe_map)) {
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
  1043
        fsm->state = ec_fsm_master_state_error;
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
  1044
        return;
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
  1045
    }
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
  1046
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
  1047
    // fetching of PDO mapping finished
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
  1048
    fsm->state = ec_fsm_master_state_end;
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
  1049
}
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
  1050
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
  1051
/*****************************************************************************/
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
  1052
72e7507b3f1b merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents: 1745
diff changeset
  1053
/**
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1054
   Master state: SDO REQUEST.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1055
*/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1056
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1057
void ec_fsm_master_state_sdo_request(ec_fsm_master_t *fsm /**< master state machine */)
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1058
{
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1059
    ec_master_t *master = fsm->master;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1060
    ec_sdo_request_t *request = fsm->sdo_request;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1061
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1062
    if (ec_fsm_coe_exec(&fsm->fsm_coe)) return;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1063
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1064
    if (!ec_fsm_coe_success(&fsm->fsm_coe)) {
1744
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1065
        EC_DBG("Failed to process SDO request for slave %i.\n",
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1066
                fsm->slave->ring_position);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1067
        request->state = EC_REQUEST_FAILURE;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1068
        wake_up(&master->sdo_queue);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1069
        fsm->state = ec_fsm_master_state_error;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1070
        return;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1071
    }
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1072
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1073
    // SDO request finished 
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1074
    request->state = EC_REQUEST_COMPLETE;
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1075
    wake_up(&master->sdo_queue);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1076
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1077
    if (master->debug_level)
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1078
        EC_DBG("Finished SDO request for slave %i.\n",
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1079
                fsm->slave->ring_position);
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1080
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1081
    // check for another SDO request
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1082
    if (ec_fsm_master_action_process_sdo(fsm))
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1083
        return; // processing another request
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1084
7bc131b92039 MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents: 1739
diff changeset
  1085
    fsm->state = ec_fsm_master_state_end;
1739
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1086
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1087
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1088
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1089
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1090
/**
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1091
   State: ERROR.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1092
*/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1093
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1094
void ec_fsm_master_state_error(
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1095
        ec_fsm_master_t *fsm /**< master state machine */
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1096
        )
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1097
{
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1098
    fsm->state = ec_fsm_master_state_start;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1099
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1100
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1101
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1102
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1103
/**
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1104
   State: END.
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1105
*/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1106
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1107
void ec_fsm_master_state_end(ec_fsm_master_t *fsm /**< master state machine */)
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1108
{
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1109
    fsm->state = ec_fsm_master_state_start;
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1110
}
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1111
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1112
/*****************************************************************************/
5fcbd29151d2 MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1113