master/fsm_slave.c
author Florian Pose <fp@igh-essen.com>
Fri, 22 Feb 2008 18:40:41 +0000
changeset 826 70aeae0de217
parent 823 24096a495dd8
permissions -rw-r--r--
Minor changes.
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 *  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *  This file is part of the IgH EtherCAT Master.
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
 *  and/or modify it under the terms of the GNU General Public License
246
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    11
 *  as published by the Free Software Foundation; either version 2 of the
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    12
 *  License, or (at your option) any later version.
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
 *
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
 *  The IgH EtherCAT Master is distributed in the hope that it will be
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
 *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
 *  GNU General Public License for more details.
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
 *
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
 *  You should have received a copy of the GNU General Public License
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
 *  along with the IgH EtherCAT Master; if not, write to the Free Software
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
 *
246
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    23
 *  The right to use EtherCAT Technology is granted and comes free of
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    24
 *  charge under condition of compatibility of product made by
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    25
 *  Licensee. People intending to distribute/sell products based on the
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    26
 *  code, have to sign an agreement to guarantee that products using
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    27
 *  software based on IgH EtherCAT master stay compatible with the actual
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    28
 *  EtherCAT specification (which are released themselves as an open
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    29
 *  standard) as the (only) precondition to have the right to use EtherCAT
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    30
 *  Technology, IP and trade marks.
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    31
 *
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
 *****************************************************************************/
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
/**
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
   \file
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    36
   EtherCAT slave state machines.
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
*/
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
/*****************************************************************************/
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
#include "globals.h"
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
#include "master.h"
329
d004349777fc SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
    43
#include "mailbox.h"
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
    44
#include "slave_config.h"
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    45
#include "fsm_slave.h"
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    46
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    47
/*****************************************************************************/
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    48
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    49
void ec_fsm_slave_scan_state_start(ec_fsm_slave_t *);
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    50
void ec_fsm_slave_scan_state_address(ec_fsm_slave_t *);
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    51
void ec_fsm_slave_scan_state_state(ec_fsm_slave_t *);
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    52
void ec_fsm_slave_scan_state_base(ec_fsm_slave_t *);
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    53
void ec_fsm_slave_scan_state_datalink(ec_fsm_slave_t *);
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    54
void ec_fsm_slave_scan_state_eeprom_size(ec_fsm_slave_t *);
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    55
void ec_fsm_slave_scan_state_eeprom_data(ec_fsm_slave_t *);
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    56
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    57
void ec_fsm_slave_conf_state_start(ec_fsm_slave_t *);
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    58
void ec_fsm_slave_conf_state_init(ec_fsm_slave_t *);
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    59
void ec_fsm_slave_conf_state_clear_fmmus(ec_fsm_slave_t *);
623
4d64368f3a1e Renamed slave configuration states "sync" to "mbox_sync" and "sync2" to
Florian Pose <fp@igh-essen.com>
parents: 620
diff changeset
    60
void ec_fsm_slave_conf_state_mbox_sync(ec_fsm_slave_t *);
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    61
void ec_fsm_slave_conf_state_preop(ec_fsm_slave_t *);
795
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
    62
void ec_fsm_slave_conf_state_sdo_conf(ec_fsm_slave_t *);
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
    63
void ec_fsm_slave_conf_state_mapping(ec_fsm_slave_t *);
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
    64
void ec_fsm_slave_conf_state_pdo_conf(ec_fsm_slave_t *);
623
4d64368f3a1e Renamed slave configuration states "sync" to "mbox_sync" and "sync2" to
Florian Pose <fp@igh-essen.com>
parents: 620
diff changeset
    65
void ec_fsm_slave_conf_state_pdo_sync(ec_fsm_slave_t *);
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    66
void ec_fsm_slave_conf_state_fmmu(ec_fsm_slave_t *);
813
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 802
diff changeset
    67
void ec_fsm_slave_conf_state_safeop(ec_fsm_slave_t *);
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    68
void ec_fsm_slave_conf_state_op(ec_fsm_slave_t *);
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    69
623
4d64368f3a1e Renamed slave configuration states "sync" to "mbox_sync" and "sync2" to
Florian Pose <fp@igh-essen.com>
parents: 620
diff changeset
    70
void ec_fsm_slave_conf_enter_mbox_sync(ec_fsm_slave_t *);
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    71
void ec_fsm_slave_conf_enter_preop(ec_fsm_slave_t *);
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
    72
void ec_fsm_slave_conf_enter_sdo_conf(ec_fsm_slave_t *);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
    73
void ec_fsm_slave_conf_enter_mapping(ec_fsm_slave_t *);
623
4d64368f3a1e Renamed slave configuration states "sync" to "mbox_sync" and "sync2" to
Florian Pose <fp@igh-essen.com>
parents: 620
diff changeset
    74
void ec_fsm_slave_conf_enter_pdo_sync(ec_fsm_slave_t *);
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    75
void ec_fsm_slave_conf_enter_fmmu(ec_fsm_slave_t *);
813
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 802
diff changeset
    76
void ec_fsm_slave_conf_enter_safeop(ec_fsm_slave_t *);
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    77
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    78
void ec_fsm_slave_state_end(ec_fsm_slave_t *);
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    79
void ec_fsm_slave_state_error(ec_fsm_slave_t *);
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
    80
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
/*****************************************************************************/
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
    83
/** Constructor.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
    84
 */
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    85
void ec_fsm_slave_init(ec_fsm_slave_t *fsm, /**< slave state machine */
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    86
        ec_datagram_t *datagram /**< datagram structure to use */
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    87
        )
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    88
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    89
    fsm->datagram = datagram;
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    90
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    91
    // init sub state machines
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    92
    ec_fsm_sii_init(&fsm->fsm_sii, fsm->datagram);
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    93
    ec_fsm_change_init(&fsm->fsm_change, fsm->datagram);
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
    94
    ec_fsm_coe_init(&fsm->fsm_coe, fsm->datagram);
802
b947d0b09f9a Renamed ec_fsm_mapping_t to ec_fsm_pdo_mapping_t.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    95
    ec_fsm_pdo_mapping_init(&fsm->fsm_pdo_map, &fsm->fsm_coe);
b947d0b09f9a Renamed ec_fsm_mapping_t to ec_fsm_pdo_mapping_t.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    96
    ec_fsm_pdo_config_init(&fsm->fsm_pdo_conf, &fsm->fsm_coe);
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
    97
}
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
    98
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
    99
/*****************************************************************************/
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   100
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   101
/** Destructor.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   102
 */
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   103
void ec_fsm_slave_clear(ec_fsm_slave_t *fsm /**< slave state machine */)
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   104
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   105
    // clear sub state machines
433
100f51f28cf2 Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
   106
    ec_fsm_sii_clear(&fsm->fsm_sii);
434
0180d8277311 Layed out state change state machine.
Florian Pose <fp@igh-essen.com>
parents: 433
diff changeset
   107
    ec_fsm_change_clear(&fsm->fsm_change);
436
63214beb641d Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 435
diff changeset
   108
    ec_fsm_coe_clear(&fsm->fsm_coe);
802
b947d0b09f9a Renamed ec_fsm_mapping_t to ec_fsm_pdo_mapping_t.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   109
    ec_fsm_pdo_mapping_clear(&fsm->fsm_pdo_map);
b947d0b09f9a Renamed ec_fsm_mapping_t to ec_fsm_pdo_mapping_t.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   110
    ec_fsm_pdo_config_clear(&fsm->fsm_pdo_conf);
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   111
}
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   112
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   113
/*****************************************************************************/
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   114
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   115
/**
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   116
 * Start slave scan state machine.
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   117
 */
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   118
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   119
void ec_fsm_slave_start_scan(ec_fsm_slave_t *fsm, /**< slave state machine */
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   120
        ec_slave_t *slave /**< slave to configure */
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   121
        )
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   122
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   123
    fsm->slave = slave;
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   124
    fsm->state = ec_fsm_slave_scan_state_start;
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   125
}
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   126
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   127
/*****************************************************************************/
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   128
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   129
/**
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   130
 * Start slave configuration state machine.
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   131
 */
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   132
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   133
void ec_fsm_slave_start_conf(ec_fsm_slave_t *fsm, /**< slave state machine */
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   134
        ec_slave_t *slave /**< slave to configure */
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   135
        )
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   136
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   137
    fsm->slave = slave;
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   138
    fsm->state = ec_fsm_slave_conf_state_start;
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   139
}
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   140
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   141
/*****************************************************************************/
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   142
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   143
/**
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   144
   \return false, if state machine has terminated
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   145
*/
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   146
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   147
int ec_fsm_slave_running(const ec_fsm_slave_t *fsm /**< slave state machine */)
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   148
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   149
    return fsm->state != ec_fsm_slave_state_end
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   150
        && fsm->state != ec_fsm_slave_state_error;
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
}
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
/*****************************************************************************/
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
260
5fe7df7f2433 Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents: 259
diff changeset
   155
/**
5fe7df7f2433 Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents: 259
diff changeset
   156
   Executes the current state of the state machine.
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   157
   If the state machine's datagram is not sent or received yet, the execution
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   158
   of the state machine is delayed to the next cycle.
435
779a18d12e6c Removed state machine running() methods.
Florian Pose <fp@igh-essen.com>
parents: 434
diff changeset
   159
   \return false, if state machine has terminated
779a18d12e6c Removed state machine running() methods.
Florian Pose <fp@igh-essen.com>
parents: 434
diff changeset
   160
*/
779a18d12e6c Removed state machine running() methods.
Florian Pose <fp@igh-essen.com>
parents: 434
diff changeset
   161
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   162
int ec_fsm_slave_exec(ec_fsm_slave_t *fsm /**< slave state machine */)
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   163
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   164
    if (fsm->datagram->state == EC_DATAGRAM_SENT
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   165
        || fsm->datagram->state == EC_DATAGRAM_QUEUED) {
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   166
        // datagram was not sent or received yet.
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   167
        return ec_fsm_slave_running(fsm);
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   168
    }
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   169
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   170
    fsm->state(fsm);
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   171
    return ec_fsm_slave_running(fsm);
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   172
}
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   173
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   174
/*****************************************************************************/
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   175
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   176
/**
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   177
   \return true, if the state machine terminated gracefully
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   178
*/
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   179
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   180
int ec_fsm_slave_success(const ec_fsm_slave_t *fsm /**< slave state machine */)
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   181
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   182
    return fsm->state == ec_fsm_slave_state_end;
446
8fede404c01f Persistent slave lists.
Florian Pose <fp@igh-essen.com>
parents: 442
diff changeset
   183
}
8fede404c01f Persistent slave lists.
Florian Pose <fp@igh-essen.com>
parents: 442
diff changeset
   184
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
/******************************************************************************
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
   186
 *  slave scan state machine
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
 *****************************************************************************/
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
/**
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   190
   Slave scan state: START.
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
   First state of the slave state machine. Writes the station address to the
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   192
   slave, according to its ring position.
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
*/
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   194
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   195
void ec_fsm_slave_scan_state_start(ec_fsm_slave_t *fsm /**< slave state machine */)
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   196
{
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
    // write station address
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   198
    ec_datagram_apwr(fsm->datagram, fsm->slave->ring_position, 0x0010, 2);
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   199
    EC_WRITE_U16(fsm->datagram->data, fsm->slave->station_address);
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   200
    fsm->retries = EC_FSM_RETRIES;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   201
    fsm->state = ec_fsm_slave_scan_state_address;
310
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   202
}
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   203
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   204
/*****************************************************************************/
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   205
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   206
/**
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   207
   Slave scan state: ADDRESS.
310
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   208
*/
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   209
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   210
void ec_fsm_slave_scan_state_address(ec_fsm_slave_t *fsm /**< slave state machine */)
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   211
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   212
    ec_datagram_t *datagram = fsm->datagram;
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 292
diff changeset
   213
637
d5d04c868e0e Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   214
    if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
d5d04c868e0e Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   215
        return;
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   216
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   217
    if (datagram->state != EC_DATAGRAM_RECEIVED) {
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   218
        fsm->state = ec_fsm_slave_state_error;
594
07dd2a7df66e Added datagram state to "Failed to receive..." messages.
Florian Pose <fp@igh-essen.com>
parents: 556
diff changeset
   219
        EC_ERR("Failed to receive station address datagram for slave %i"
07dd2a7df66e Added datagram state to "Failed to receive..." messages.
Florian Pose <fp@igh-essen.com>
parents: 556
diff changeset
   220
                " (datagram state %i)\n",
07dd2a7df66e Added datagram state to "Failed to receive..." messages.
Florian Pose <fp@igh-essen.com>
parents: 556
diff changeset
   221
                fsm->slave->ring_position, datagram->state);
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   222
        return;
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   223
    }
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   224
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   225
    if (datagram->working_counter != 1) {
292
2cf6ae0a2419 Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents: 291
diff changeset
   226
        fsm->slave->error_flag = 1;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   227
        fsm->state = ec_fsm_slave_state_error;
713
ae41cadd25b6 Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents: 696
diff changeset
   228
        EC_ERR("Failed to write station address on slave %i: ",
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
               fsm->slave->ring_position);
713
ae41cadd25b6 Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents: 696
diff changeset
   230
        ec_datagram_print_wc_error(datagram);
292
2cf6ae0a2419 Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents: 291
diff changeset
   231
        return;
2cf6ae0a2419 Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents: 291
diff changeset
   232
    }
2cf6ae0a2419 Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents: 291
diff changeset
   233
2cf6ae0a2419 Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents: 291
diff changeset
   234
    // Read AL state
815
002fe9ec778f Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   235
    ec_datagram_fprd(datagram, fsm->slave->station_address, 0x0130, 2);
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   236
    fsm->retries = EC_FSM_RETRIES;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   237
    fsm->state = ec_fsm_slave_scan_state_state;
310
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   238
}
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   239
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   240
/*****************************************************************************/
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   241
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   242
/**
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   243
   Slave scan state: STATE.
310
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   244
*/
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   245
713
ae41cadd25b6 Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents: 696
diff changeset
   246
void ec_fsm_slave_scan_state_state(
ae41cadd25b6 Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents: 696
diff changeset
   247
        ec_fsm_slave_t *fsm /**< slave state machine */
ae41cadd25b6 Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents: 696
diff changeset
   248
        )
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   249
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   250
    ec_datagram_t *datagram = fsm->datagram;
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 292
diff changeset
   251
    ec_slave_t *slave = fsm->slave;
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 292
diff changeset
   252
637
d5d04c868e0e Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   253
    if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
d5d04c868e0e Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   254
        return;
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   255
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   256
    if (datagram->state != EC_DATAGRAM_RECEIVED) {
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   257
        fsm->state = ec_fsm_slave_state_error;
594
07dd2a7df66e Added datagram state to "Failed to receive..." messages.
Florian Pose <fp@igh-essen.com>
parents: 556
diff changeset
   258
        EC_ERR("Failed to receive AL state datagram from slave %i"
07dd2a7df66e Added datagram state to "Failed to receive..." messages.
Florian Pose <fp@igh-essen.com>
parents: 556
diff changeset
   259
                " (datagram state %i).\n",
07dd2a7df66e Added datagram state to "Failed to receive..." messages.
Florian Pose <fp@igh-essen.com>
parents: 556
diff changeset
   260
               fsm->slave->ring_position, datagram->state);
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   261
        return;
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   262
    }
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   263
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   264
    if (datagram->working_counter != 1) {
291
0b1f877cf3f1 Slave: state_error -> error_flag, error_flag only in slave state machine.
Florian Pose <fp@igh-essen.com>
parents: 290
diff changeset
   265
        fsm->slave->error_flag = 1;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   266
        fsm->state = ec_fsm_slave_state_error;
713
ae41cadd25b6 Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents: 696
diff changeset
   267
        EC_ERR("Failed to read AL state of slave %i: ",
255
6b916cce7f27 Read current AL status of slaves while scanning bus.
Florian Pose <fp@igh-essen.com>
parents: 254
diff changeset
   268
               fsm->slave->ring_position);
713
ae41cadd25b6 Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents: 696
diff changeset
   269
        ec_datagram_print_wc_error(datagram);
255
6b916cce7f27 Read current AL status of slaves while scanning bus.
Florian Pose <fp@igh-essen.com>
parents: 254
diff changeset
   270
        return;
6b916cce7f27 Read current AL status of slaves while scanning bus.
Florian Pose <fp@igh-essen.com>
parents: 254
diff changeset
   271
    }
6b916cce7f27 Read current AL status of slaves while scanning bus.
Florian Pose <fp@igh-essen.com>
parents: 254
diff changeset
   272
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 292
diff changeset
   273
    slave->current_state = EC_READ_U8(datagram->data);
402
03e31ac14047 Renamed EC_ACK to EC_SLAVE_STATE_ACK_ERR
Florian Pose <fp@igh-essen.com>
parents: 398
diff changeset
   274
    if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) {
454
25cc4a3b9e0a State acknowledgement in master state machine.
Florian Pose <fp@igh-essen.com>
parents: 448
diff changeset
   275
        char state_str[EC_STATE_STRING_SIZE];
25cc4a3b9e0a State acknowledgement in master state machine.
Florian Pose <fp@igh-essen.com>
parents: 448
diff changeset
   276
        ec_state_string(slave->current_state, state_str);
25cc4a3b9e0a State acknowledgement in master state machine.
Florian Pose <fp@igh-essen.com>
parents: 448
diff changeset
   277
        EC_WARN("Slave %i has state error bit set (%s)!\n",
25cc4a3b9e0a State acknowledgement in master state machine.
Florian Pose <fp@igh-essen.com>
parents: 448
diff changeset
   278
                slave->ring_position, state_str);
255
6b916cce7f27 Read current AL status of slaves while scanning bus.
Florian Pose <fp@igh-essen.com>
parents: 254
diff changeset
   279
    }
6b916cce7f27 Read current AL status of slaves while scanning bus.
Florian Pose <fp@igh-essen.com>
parents: 254
diff changeset
   280
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   281
    // read base data
815
002fe9ec778f Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   282
    ec_datagram_fprd(datagram, fsm->slave->station_address, 0x0000, 6);
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   283
    fsm->retries = EC_FSM_RETRIES;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   284
    fsm->state = ec_fsm_slave_scan_state_base;
310
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   285
}
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   286
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   287
/*****************************************************************************/
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   288
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   289
/**
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   290
   Slave scan state: BASE.
310
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   291
*/
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   292
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   293
void ec_fsm_slave_scan_state_base(ec_fsm_slave_t *fsm /**< slave state machine */)
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   294
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   295
    ec_datagram_t *datagram = fsm->datagram;
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 292
diff changeset
   296
    ec_slave_t *slave = fsm->slave;
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 292
diff changeset
   297
637
d5d04c868e0e Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   298
    if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
d5d04c868e0e Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   299
        return;
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   300
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   301
    if (datagram->state != EC_DATAGRAM_RECEIVED) {
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   302
        fsm->state = ec_fsm_slave_state_error;
594
07dd2a7df66e Added datagram state to "Failed to receive..." messages.
Florian Pose <fp@igh-essen.com>
parents: 556
diff changeset
   303
        EC_ERR("Failed to receive base data datagram for slave %i"
07dd2a7df66e Added datagram state to "Failed to receive..." messages.
Florian Pose <fp@igh-essen.com>
parents: 556
diff changeset
   304
                " (datagram state %i).\n",
07dd2a7df66e Added datagram state to "Failed to receive..." messages.
Florian Pose <fp@igh-essen.com>
parents: 556
diff changeset
   305
               slave->ring_position, datagram->state);
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   306
        return;
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   307
    }
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   308
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   309
    if (datagram->working_counter != 1) {
291
0b1f877cf3f1 Slave: state_error -> error_flag, error_flag only in slave state machine.
Florian Pose <fp@igh-essen.com>
parents: 290
diff changeset
   310
        fsm->slave->error_flag = 1;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   311
        fsm->state = ec_fsm_slave_state_error;
713
ae41cadd25b6 Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents: 696
diff changeset
   312
        EC_ERR("Failed to read base data from slave %i: ",
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   313
               slave->ring_position);
713
ae41cadd25b6 Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents: 696
diff changeset
   314
        ec_datagram_print_wc_error(datagram);
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
        return;
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
    }
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   317
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 292
diff changeset
   318
    slave->base_type       = EC_READ_U8 (datagram->data);
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 292
diff changeset
   319
    slave->base_revision   = EC_READ_U8 (datagram->data + 1);
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 292
diff changeset
   320
    slave->base_build      = EC_READ_U16(datagram->data + 2);
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 292
diff changeset
   321
    slave->base_fmmu_count = EC_READ_U8 (datagram->data + 4);
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
823
24096a495dd8 Check for FMMU limits.
Florian Pose <fp@igh-essen.com>
parents: 822
diff changeset
   323
    if (slave->base_fmmu_count > EC_MAX_FMMUS) {
24096a495dd8 Check for FMMU limits.
Florian Pose <fp@igh-essen.com>
parents: 822
diff changeset
   324
        EC_WARN("Slave %u has more FMMUs (%u) than the master can"
24096a495dd8 Check for FMMU limits.
Florian Pose <fp@igh-essen.com>
parents: 822
diff changeset
   325
                " handle (%u).\n", slave->ring_position,
24096a495dd8 Check for FMMU limits.
Florian Pose <fp@igh-essen.com>
parents: 822
diff changeset
   326
                slave->base_fmmu_count, EC_MAX_FMMUS);
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   327
        slave->base_fmmu_count = EC_MAX_FMMUS;
823
24096a495dd8 Check for FMMU limits.
Florian Pose <fp@igh-essen.com>
parents: 822
diff changeset
   328
    }
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   329
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   330
    // read data link status
815
002fe9ec778f Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   331
    ec_datagram_fprd(datagram, slave->station_address, 0x0110, 2);
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   332
    fsm->retries = EC_FSM_RETRIES;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   333
    fsm->state = ec_fsm_slave_scan_state_datalink;
310
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   334
}
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   335
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   336
/*****************************************************************************/
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   337
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   338
/**
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   339
   Slave scan state: DATALINK.
310
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   340
*/
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   341
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   342
void ec_fsm_slave_scan_state_datalink(ec_fsm_slave_t *fsm /**< slave state machine */)
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   343
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   344
    ec_datagram_t *datagram = fsm->datagram;
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   345
    ec_slave_t *slave = fsm->slave;
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   346
    uint16_t dl_status;
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   347
    unsigned int i;
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   348
637
d5d04c868e0e Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   349
    if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
d5d04c868e0e Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   350
        return;
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   351
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   352
    if (datagram->state != EC_DATAGRAM_RECEIVED) {
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   353
        fsm->state = ec_fsm_slave_state_error;
594
07dd2a7df66e Added datagram state to "Failed to receive..." messages.
Florian Pose <fp@igh-essen.com>
parents: 556
diff changeset
   354
        EC_ERR("Failed to receive DL status datagram from slave %i"
07dd2a7df66e Added datagram state to "Failed to receive..." messages.
Florian Pose <fp@igh-essen.com>
parents: 556
diff changeset
   355
                " (datagram state %i).\n",
07dd2a7df66e Added datagram state to "Failed to receive..." messages.
Florian Pose <fp@igh-essen.com>
parents: 556
diff changeset
   356
               slave->ring_position, datagram->state);
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   357
        return;
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   358
    }
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   359
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   360
    if (datagram->working_counter != 1) {
291
0b1f877cf3f1 Slave: state_error -> error_flag, error_flag only in slave state machine.
Florian Pose <fp@igh-essen.com>
parents: 290
diff changeset
   361
        fsm->slave->error_flag = 1;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   362
        fsm->state = ec_fsm_slave_state_error;
713
ae41cadd25b6 Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents: 696
diff changeset
   363
        EC_ERR("Failed to read DL status from slave %i: ",
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   364
               slave->ring_position);
713
ae41cadd25b6 Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents: 696
diff changeset
   365
        ec_datagram_print_wc_error(datagram);
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   366
        return;
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   367
    }
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   368
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 292
diff changeset
   369
    dl_status = EC_READ_U16(datagram->data);
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   370
    for (i = 0; i < 4; i++) {
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   371
        slave->dl_link[i] = dl_status & (1 << (4 + i)) ? 1 : 0;
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   372
        slave->dl_loop[i] = dl_status & (1 << (8 + i * 2)) ? 1 : 0;
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   373
        slave->dl_signal[i] = dl_status & (1 << (9 + i * 2)) ? 1 : 0;
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   374
    }
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   375
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   376
    // Start fetching EEPROM size
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   377
696
24fac09b5b26 Limited EEPROM reading; added EC_FIRST_EEPROM_CATEGORY_HEADER define.
Florian Pose <fp@igh-essen.com>
parents: 637
diff changeset
   378
    fsm->sii_offset = EC_FIRST_EEPROM_CATEGORY_OFFSET; // first category header
815
002fe9ec778f Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   379
    ec_fsm_sii_read(&fsm->fsm_sii, slave, fsm->sii_offset,
002fe9ec778f Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   380
            EC_FSM_SII_USE_CONFIGURED_ADDRESS);
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   381
    fsm->state = ec_fsm_slave_scan_state_eeprom_size;
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   382
    fsm->state(fsm); // execute state immediately
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   383
}
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   384
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   385
/*****************************************************************************/
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   386
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   387
/**
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   388
   Slave scan state: EEPROM SIZE.
310
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   389
*/
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   390
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   391
void ec_fsm_slave_scan_state_eeprom_size(ec_fsm_slave_t *fsm /**< slave state machine */)
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   392
{
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   393
    ec_slave_t *slave = fsm->slave;
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   394
    uint16_t cat_type, cat_size;
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   395
435
779a18d12e6c Removed state machine running() methods.
Florian Pose <fp@igh-essen.com>
parents: 434
diff changeset
   396
    if (ec_fsm_sii_exec(&fsm->fsm_sii)) return;
433
100f51f28cf2 Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
   397
100f51f28cf2 Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
   398
    if (!ec_fsm_sii_success(&fsm->fsm_sii)) {
292
2cf6ae0a2419 Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents: 291
diff changeset
   399
        fsm->slave->error_flag = 1;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   400
        fsm->state = ec_fsm_slave_state_error;
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   401
        EC_ERR("Failed to read EEPROM size of slave %i.\n",
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   402
               slave->ring_position);
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   403
        return;
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   404
    }
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   405
433
100f51f28cf2 Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
   406
    cat_type = EC_READ_U16(fsm->fsm_sii.value);
100f51f28cf2 Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
   407
    cat_size = EC_READ_U16(fsm->fsm_sii.value + 2);
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   408
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   409
    if (cat_type != 0xFFFF) { // not the last category
744
b83392e8cd66 Fixed detection of missing EEPROM category limiter.
Florian Pose <fp@igh-essen.com>
parents: 742
diff changeset
   410
        off_t next_offset = 2UL + fsm->sii_offset + cat_size;
b83392e8cd66 Fixed detection of missing EEPROM category limiter.
Florian Pose <fp@igh-essen.com>
parents: 742
diff changeset
   411
        if (next_offset >= EC_MAX_EEPROM_SIZE) {
696
24fac09b5b26 Limited EEPROM reading; added EC_FIRST_EEPROM_CATEGORY_HEADER define.
Florian Pose <fp@igh-essen.com>
parents: 637
diff changeset
   412
            EC_WARN("EEPROM size of slave %i exceeds"
744
b83392e8cd66 Fixed detection of missing EEPROM category limiter.
Florian Pose <fp@igh-essen.com>
parents: 742
diff changeset
   413
                    " %u words (0xffff limiter missing?).\n",
696
24fac09b5b26 Limited EEPROM reading; added EC_FIRST_EEPROM_CATEGORY_HEADER define.
Florian Pose <fp@igh-essen.com>
parents: 637
diff changeset
   414
                    slave->ring_position, EC_MAX_EEPROM_SIZE);
771
9946a675f86e Cut off category data on exceeding eeprom size limit.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   415
            // cut off category data...
696
24fac09b5b26 Limited EEPROM reading; added EC_FIRST_EEPROM_CATEGORY_HEADER define.
Florian Pose <fp@igh-essen.com>
parents: 637
diff changeset
   416
            slave->eeprom_size = EC_FIRST_EEPROM_CATEGORY_OFFSET * 2;
24fac09b5b26 Limited EEPROM reading; added EC_FIRST_EEPROM_CATEGORY_HEADER define.
Florian Pose <fp@igh-essen.com>
parents: 637
diff changeset
   417
            goto alloc_eeprom;
24fac09b5b26 Limited EEPROM reading; added EC_FIRST_EEPROM_CATEGORY_HEADER define.
Florian Pose <fp@igh-essen.com>
parents: 637
diff changeset
   418
        }
744
b83392e8cd66 Fixed detection of missing EEPROM category limiter.
Florian Pose <fp@igh-essen.com>
parents: 742
diff changeset
   419
        fsm->sii_offset = next_offset;
433
100f51f28cf2 Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
   420
        ec_fsm_sii_read(&fsm->fsm_sii, slave, fsm->sii_offset,
815
002fe9ec778f Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   421
                        EC_FSM_SII_USE_CONFIGURED_ADDRESS);
433
100f51f28cf2 Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
   422
        ec_fsm_sii_exec(&fsm->fsm_sii); // execute state immediately
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   423
        return;
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   424
    }
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   425
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   426
    slave->eeprom_size = (fsm->sii_offset + 1) * 2;
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   427
696
24fac09b5b26 Limited EEPROM reading; added EC_FIRST_EEPROM_CATEGORY_HEADER define.
Florian Pose <fp@igh-essen.com>
parents: 637
diff changeset
   428
alloc_eeprom:
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   429
    if (slave->eeprom_data) {
744
b83392e8cd66 Fixed detection of missing EEPROM category limiter.
Florian Pose <fp@igh-essen.com>
parents: 742
diff changeset
   430
        EC_WARN("Freeing old EEPROM data on slave %i...\n",
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   431
                slave->ring_position);
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   432
        kfree(slave->eeprom_data);
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   433
    }
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   434
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   435
    if (!(slave->eeprom_data =
734
8c9d62f7c2cd Minor fix: Set eeprom_size to 0 on unsuccessful memory allocation.
Florian Pose <fp@igh-essen.com>
parents: 731
diff changeset
   436
                (uint8_t *) kmalloc(slave->eeprom_size, GFP_ATOMIC))) {
744
b83392e8cd66 Fixed detection of missing EEPROM category limiter.
Florian Pose <fp@igh-essen.com>
parents: 742
diff changeset
   437
        EC_ERR("Failed to allocate %u bytes of EEPROM data for slave %u.\n",
b83392e8cd66 Fixed detection of missing EEPROM category limiter.
Florian Pose <fp@igh-essen.com>
parents: 742
diff changeset
   438
               slave->eeprom_size, slave->ring_position);
734
8c9d62f7c2cd Minor fix: Set eeprom_size to 0 on unsuccessful memory allocation.
Florian Pose <fp@igh-essen.com>
parents: 731
diff changeset
   439
        slave->eeprom_size = 0;
8c9d62f7c2cd Minor fix: Set eeprom_size to 0 on unsuccessful memory allocation.
Florian Pose <fp@igh-essen.com>
parents: 731
diff changeset
   440
        slave->error_flag = 1;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   441
        fsm->state = ec_fsm_slave_state_error;
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   442
        return;
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   443
    }
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   444
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   445
    // Start fetching EEPROM contents
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   446
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   447
    fsm->state = ec_fsm_slave_scan_state_eeprom_data;
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   448
    fsm->sii_offset = 0x0000;
815
002fe9ec778f Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   449
    ec_fsm_sii_read(&fsm->fsm_sii, slave, fsm->sii_offset,
002fe9ec778f Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   450
            EC_FSM_SII_USE_CONFIGURED_ADDRESS);
433
100f51f28cf2 Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
   451
    ec_fsm_sii_exec(&fsm->fsm_sii); // execute state immediately
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   452
}
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   453
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   454
/*****************************************************************************/
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   455
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   456
/**
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   457
   Slave scan state: EEPROM DATA.
310
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   458
*/
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   459
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   460
void ec_fsm_slave_scan_state_eeprom_data(ec_fsm_slave_t *fsm /**< slave state machine */)
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   461
{
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   462
    ec_slave_t *slave = fsm->slave;
742
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   463
    uint16_t *cat_word, cat_type, cat_size, eeprom_word_size = slave->eeprom_size / 2;
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   464
435
779a18d12e6c Removed state machine running() methods.
Florian Pose <fp@igh-essen.com>
parents: 434
diff changeset
   465
    if (ec_fsm_sii_exec(&fsm->fsm_sii)) return;
433
100f51f28cf2 Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
   466
100f51f28cf2 Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
   467
    if (!ec_fsm_sii_success(&fsm->fsm_sii)) {
292
2cf6ae0a2419 Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents: 291
diff changeset
   468
        fsm->slave->error_flag = 1;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   469
        fsm->state = ec_fsm_slave_state_error;
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   470
        EC_ERR("Failed to fetch EEPROM contents of slave %i.\n",
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   471
               slave->ring_position);
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   472
        return;
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   473
    }
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   474
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   475
    // 2 words fetched
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   476
742
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   477
    if (fsm->sii_offset + 2 <= eeprom_word_size) { // 2 words fit
433
100f51f28cf2 Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
   478
        memcpy(slave->eeprom_data + fsm->sii_offset * 2,
100f51f28cf2 Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
   479
               fsm->fsm_sii.value, 4);
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   480
    }
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   481
    else { // copy the last word
433
100f51f28cf2 Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
   482
        memcpy(slave->eeprom_data + fsm->sii_offset * 2,
100f51f28cf2 Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
   483
               fsm->fsm_sii.value, 2);
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   484
    }
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   485
742
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   486
    if (fsm->sii_offset + 2 < eeprom_word_size) {
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   487
        // fetch the next 2 words
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   488
        fsm->sii_offset += 2;
433
100f51f28cf2 Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
   489
        ec_fsm_sii_read(&fsm->fsm_sii, slave, fsm->sii_offset,
815
002fe9ec778f Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   490
                        EC_FSM_SII_USE_CONFIGURED_ADDRESS);
433
100f51f28cf2 Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
   491
        ec_fsm_sii_exec(&fsm->fsm_sii); // execute state immediately
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   492
        return;
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   493
    }
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   494
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   495
    // Evaluate EEPROM contents
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   496
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   497
    slave->sii_alias =
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   498
        EC_READ_U16(slave->eeprom_data + 2 * 0x0004);
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   499
    slave->sii_vendor_id =
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   500
        EC_READ_U32(slave->eeprom_data + 2 * 0x0008);
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   501
    slave->sii_product_code =
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   502
        EC_READ_U32(slave->eeprom_data + 2 * 0x000A);
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   503
    slave->sii_revision_number =
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   504
        EC_READ_U32(slave->eeprom_data + 2 * 0x000C);
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   505
    slave->sii_serial_number =
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   506
        EC_READ_U32(slave->eeprom_data + 2 * 0x000E);
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   507
    slave->sii_rx_mailbox_offset =
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   508
        EC_READ_U16(slave->eeprom_data + 2 * 0x0018);
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   509
    slave->sii_rx_mailbox_size =
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   510
        EC_READ_U16(slave->eeprom_data + 2 * 0x0019);
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   511
    slave->sii_tx_mailbox_offset =
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   512
        EC_READ_U16(slave->eeprom_data + 2 * 0x001A);
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   513
    slave->sii_tx_mailbox_size =
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   514
        EC_READ_U16(slave->eeprom_data + 2 * 0x001B);
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   515
    slave->sii_mailbox_protocols =
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   516
        EC_READ_U16(slave->eeprom_data + 2 * 0x001C);
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   517
771
9946a675f86e Cut off category data on exceeding eeprom size limit.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   518
    if (eeprom_word_size == EC_FIRST_EEPROM_CATEGORY_OFFSET) {
9946a675f86e Cut off category data on exceeding eeprom size limit.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   519
        // eeprom does not contain category data
9946a675f86e Cut off category data on exceeding eeprom size limit.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   520
        fsm->state = ec_fsm_slave_state_end;
9946a675f86e Cut off category data on exceeding eeprom size limit.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   521
        return;
9946a675f86e Cut off category data on exceeding eeprom size limit.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   522
    }
9946a675f86e Cut off category data on exceeding eeprom size limit.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   523
742
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   524
    if (eeprom_word_size < EC_FIRST_EEPROM_CATEGORY_OFFSET + 1) {
744
b83392e8cd66 Fixed detection of missing EEPROM category limiter.
Florian Pose <fp@igh-essen.com>
parents: 742
diff changeset
   525
        EC_ERR("Unexpected end of EEPROM data in slave %u:"
b83392e8cd66 Fixed detection of missing EEPROM category limiter.
Florian Pose <fp@igh-essen.com>
parents: 742
diff changeset
   526
                " First category header missing.\n",
742
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   527
                slave->ring_position);
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   528
        goto end;
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   529
    }
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   530
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   531
    // evaluate category data
742
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   532
    cat_word =
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   533
        (uint16_t *) slave->eeprom_data + EC_FIRST_EEPROM_CATEGORY_OFFSET;
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   534
    while (EC_READ_U16(cat_word) != 0xFFFF) {
742
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   535
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   536
        // type and size words must fit
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   537
        if (cat_word + 2 - (uint16_t *) slave->eeprom_data
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   538
                > eeprom_word_size) {
744
b83392e8cd66 Fixed detection of missing EEPROM category limiter.
Florian Pose <fp@igh-essen.com>
parents: 742
diff changeset
   539
            EC_ERR("Unexpected end of EEPROM data in slave %u:"
b83392e8cd66 Fixed detection of missing EEPROM category limiter.
Florian Pose <fp@igh-essen.com>
parents: 742
diff changeset
   540
                    " Category header incomplete.\n",
742
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   541
                    slave->ring_position);
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   542
            goto end;
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   543
        }
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   544
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   545
        cat_type = EC_READ_U16(cat_word) & 0x7FFF;
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   546
        cat_size = EC_READ_U16(cat_word + 1);
742
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   547
        cat_word += 2;
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   548
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   549
        if (cat_word + cat_size - (uint16_t *) slave->eeprom_data
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   550
                > eeprom_word_size) {
744
b83392e8cd66 Fixed detection of missing EEPROM category limiter.
Florian Pose <fp@igh-essen.com>
parents: 742
diff changeset
   551
            EC_WARN("Unexpected end of EEPROM data in slave %u:"
b83392e8cd66 Fixed detection of missing EEPROM category limiter.
Florian Pose <fp@igh-essen.com>
parents: 742
diff changeset
   552
                    " Category data incomplete.\n",
742
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   553
                    slave->ring_position);
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   554
            goto end;
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   555
        }
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   556
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   557
        switch (cat_type) {
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   558
            case 0x000A:
742
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   559
                if (ec_slave_fetch_sii_strings(slave, (uint8_t *) cat_word,
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   560
                            cat_size * 2))
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   561
                    goto end;
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   562
                break;
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   563
            case 0x001E:
742
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   564
                if (ec_slave_fetch_sii_general(slave, (uint8_t *) cat_word,
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   565
                            cat_size * 2))
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   566
                    goto end;
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   567
                break;
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   568
            case 0x0028:
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   569
                break;
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   570
            case 0x0029:
742
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   571
                if (ec_slave_fetch_sii_syncs(slave, (uint8_t *) cat_word,
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   572
                            cat_size * 2))
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   573
                    goto end;
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   574
                break;
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   575
            case 0x0032:
742
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   576
                if (ec_slave_fetch_sii_pdos( slave, (uint8_t *) cat_word,
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   577
                            cat_size * 2, EC_DIR_INPUT)) // TxPdo
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   578
                    goto end;
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   579
                break;
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   580
            case 0x0033:
742
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   581
                if (ec_slave_fetch_sii_pdos( slave, (uint8_t *) cat_word,
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   582
                            cat_size * 2, EC_DIR_OUTPUT)) // RxPdo
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   583
                    goto end;
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   584
                break;
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   585
            default:
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   586
                if (fsm->slave->master->debug_level)
461
b9eda9235173 Print certain warnings only at debug_level.
Florian Pose <fp@igh-essen.com>
parents: 459
diff changeset
   587
                    EC_WARN("Unknown category type 0x%04X in slave %i.\n",
b9eda9235173 Print certain warnings only at debug_level.
Florian Pose <fp@igh-essen.com>
parents: 459
diff changeset
   588
                            cat_type, slave->ring_position);
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   589
        }
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   590
742
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   591
        cat_word += cat_size;
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   592
        if (cat_word - (uint16_t *) slave->eeprom_data >= eeprom_word_size) {
744
b83392e8cd66 Fixed detection of missing EEPROM category limiter.
Florian Pose <fp@igh-essen.com>
parents: 742
diff changeset
   593
            EC_WARN("Unexpected end of EEPROM data in slave %u:"
b83392e8cd66 Fixed detection of missing EEPROM category limiter.
Florian Pose <fp@igh-essen.com>
parents: 742
diff changeset
   594
                    " Next category header missing.\n",
742
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   595
                    slave->ring_position);
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   596
            goto end;
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 738
diff changeset
   597
        }
266
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   598
    }
0234b0c26c52 Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents: 262
diff changeset
   599
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   600
    fsm->state = ec_fsm_slave_state_end;
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
   601
    return;
310
b7e7709fd40e Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 309
diff changeset
   602
292
2cf6ae0a2419 Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents: 291
diff changeset
   603
end:
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
   604
    EC_ERR("Failed to analyze category data.\n");
291
0b1f877cf3f1 Slave: state_error -> error_flag, error_flag only in slave state machine.
Florian Pose <fp@igh-essen.com>
parents: 290
diff changeset
   605
    fsm->slave->error_flag = 1;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   606
    fsm->state = ec_fsm_slave_state_error;
308
d50b139c8601 Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 306
diff changeset
   607
}
d50b139c8601 Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 306
diff changeset
   608
d50b139c8601 Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 306
diff changeset
   609
/******************************************************************************
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
   610
 *  slave configuration state machine
308
d50b139c8601 Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 306
diff changeset
   611
 *****************************************************************************/
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   612
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   613
/**
456
dea14706efc2 Explicit use of slave configuration FSM in ecrt_master_activate() and ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents: 454
diff changeset
   614
   Slave configuration state: START.
dea14706efc2 Explicit use of slave configuration FSM in ecrt_master_activate() and ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents: 454
diff changeset
   615
*/
dea14706efc2 Explicit use of slave configuration FSM in ecrt_master_activate() and ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents: 454
diff changeset
   616
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   617
void ec_fsm_slave_conf_state_start(ec_fsm_slave_t *fsm /**< slave state machine */)
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   618
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   619
    if (fsm->slave->master->debug_level) {
456
dea14706efc2 Explicit use of slave configuration FSM in ecrt_master_activate() and ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents: 454
diff changeset
   620
        EC_DBG("Configuring slave %i...\n", fsm->slave->ring_position);
dea14706efc2 Explicit use of slave configuration FSM in ecrt_master_activate() and ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents: 454
diff changeset
   621
    }
dea14706efc2 Explicit use of slave configuration FSM in ecrt_master_activate() and ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents: 454
diff changeset
   622
dea14706efc2 Explicit use of slave configuration FSM in ecrt_master_activate() and ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents: 454
diff changeset
   623
    ec_fsm_change_start(&fsm->fsm_change, fsm->slave, EC_SLAVE_STATE_INIT);
dea14706efc2 Explicit use of slave configuration FSM in ecrt_master_activate() and ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents: 454
diff changeset
   624
    ec_fsm_change_exec(&fsm->fsm_change);
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   625
    fsm->state = ec_fsm_slave_conf_state_init;
456
dea14706efc2 Explicit use of slave configuration FSM in ecrt_master_activate() and ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents: 454
diff changeset
   626
}
dea14706efc2 Explicit use of slave configuration FSM in ecrt_master_activate() and ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents: 454
diff changeset
   627
dea14706efc2 Explicit use of slave configuration FSM in ecrt_master_activate() and ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents: 454
diff changeset
   628
/*****************************************************************************/
dea14706efc2 Explicit use of slave configuration FSM in ecrt_master_activate() and ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents: 454
diff changeset
   629
dea14706efc2 Explicit use of slave configuration FSM in ecrt_master_activate() and ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents: 454
diff changeset
   630
/**
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   631
   Slave configuration state: INIT.
309
42e69cf31495 Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 308
diff changeset
   632
*/
42e69cf31495 Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 308
diff changeset
   633
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   634
void ec_fsm_slave_conf_state_init(ec_fsm_slave_t *fsm /**< slave state machine */)
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   635
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   636
    ec_master_t *master = fsm->slave->master;
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   637
    ec_slave_t *slave = fsm->slave;
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   638
    ec_datagram_t *datagram = fsm->datagram;
462
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   639
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   640
    if (ec_fsm_change_exec(&fsm->fsm_change)) return;
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   641
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   642
    if (!ec_fsm_change_success(&fsm->fsm_change)) {
738
880c6153101f Improved handling for spontaneous AL state changes.
Florian Pose <fp@igh-essen.com>
parents: 737
diff changeset
   643
        if (!fsm->fsm_change.spontaneous_change)
880c6153101f Improved handling for spontaneous AL state changes.
Florian Pose <fp@igh-essen.com>
parents: 737
diff changeset
   644
            slave->error_flag = 1;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   645
        fsm->state = ec_fsm_slave_state_error;
462
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   646
        return;
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   647
    }
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   648
523
584a4f60b067 Re-added slave.configured flag as slave.self_configured.
Florian Pose <fp@igh-essen.com>
parents: 522
diff changeset
   649
    slave->self_configured = 1;
584a4f60b067 Re-added slave.configured flag as slave.self_configured.
Florian Pose <fp@igh-essen.com>
parents: 522
diff changeset
   650
462
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   651
    if (master->debug_level) {
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   652
        EC_DBG("Slave %i is now in INIT.\n", slave->ring_position);
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   653
    }
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   654
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   655
    // check and reset CRC fault counters
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   656
    //ec_slave_check_crc(slave);
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   657
    // TODO: Implement state machine for CRC checking.
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   658
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   659
    if (!slave->base_fmmu_count) { // skip FMMU configuration
623
4d64368f3a1e Renamed slave configuration states "sync" to "mbox_sync" and "sync2" to
Florian Pose <fp@igh-essen.com>
parents: 620
diff changeset
   660
        ec_fsm_slave_conf_enter_mbox_sync(fsm);
462
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   661
        return;
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   662
    }
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   663
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   664
    if (master->debug_level)
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   665
        EC_DBG("Clearing FMMU configurations of slave %i...\n",
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   666
               slave->ring_position);
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   667
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   668
    // clear FMMU configurations
815
002fe9ec778f Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   669
    ec_datagram_fpwr(datagram, slave->station_address,
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   670
            0x0600, EC_FMMU_PAGE_SIZE * slave->base_fmmu_count);
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   671
    memset(datagram->data, 0x00, EC_FMMU_PAGE_SIZE * slave->base_fmmu_count);
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   672
    fsm->retries = EC_FSM_RETRIES;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   673
    fsm->state = ec_fsm_slave_conf_state_clear_fmmus;
462
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   674
}
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   675
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   676
/*****************************************************************************/
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   677
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   678
/**
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   679
   Slave configuration state: CLEAR FMMU.
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   680
*/
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   681
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   682
void ec_fsm_slave_conf_state_clear_fmmus(ec_fsm_slave_t *fsm
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   683
                                        /**< slave state machine */)
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   684
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   685
    ec_datagram_t *datagram = fsm->datagram;
462
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   686
637
d5d04c868e0e Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   687
    if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
d5d04c868e0e Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   688
        return;
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   689
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   690
    if (datagram->state != EC_DATAGRAM_RECEIVED) {
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   691
        fsm->state = ec_fsm_slave_state_error;
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   692
        EC_ERR("Failed receive FMMU clearing datagram for slave %i.\n",
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   693
               fsm->slave->ring_position);
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   694
        return;
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   695
    }
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   696
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   697
    if (datagram->working_counter != 1) {
462
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   698
        fsm->slave->error_flag = 1;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   699
        fsm->state = ec_fsm_slave_state_error;
713
ae41cadd25b6 Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents: 696
diff changeset
   700
        EC_ERR("Failed to clear FMMUs of slave %i: ",
462
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   701
               fsm->slave->ring_position);
713
ae41cadd25b6 Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents: 696
diff changeset
   702
        ec_datagram_print_wc_error(datagram);
462
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   703
        return;
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   704
    }
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   705
623
4d64368f3a1e Renamed slave configuration states "sync" to "mbox_sync" and "sync2" to
Florian Pose <fp@igh-essen.com>
parents: 620
diff changeset
   706
    ec_fsm_slave_conf_enter_mbox_sync(fsm);
4d64368f3a1e Renamed slave configuration states "sync" to "mbox_sync" and "sync2" to
Florian Pose <fp@igh-essen.com>
parents: 620
diff changeset
   707
}
4d64368f3a1e Renamed slave configuration states "sync" to "mbox_sync" and "sync2" to
Florian Pose <fp@igh-essen.com>
parents: 620
diff changeset
   708
4d64368f3a1e Renamed slave configuration states "sync" to "mbox_sync" and "sync2" to
Florian Pose <fp@igh-essen.com>
parents: 620
diff changeset
   709
/*****************************************************************************/
4d64368f3a1e Renamed slave configuration states "sync" to "mbox_sync" and "sync2" to
Florian Pose <fp@igh-essen.com>
parents: 620
diff changeset
   710
4d64368f3a1e Renamed slave configuration states "sync" to "mbox_sync" and "sync2" to
Florian Pose <fp@igh-essen.com>
parents: 620
diff changeset
   711
/**
758
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 744
diff changeset
   712
 * Check for mailbox sync managers to be configured.
628
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents: 623
diff changeset
   713
 */
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents: 623
diff changeset
   714
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents: 623
diff changeset
   715
void ec_fsm_slave_conf_enter_mbox_sync(
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents: 623
diff changeset
   716
        ec_fsm_slave_t *fsm /**< slave state machine */
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents: 623
diff changeset
   717
        )
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   718
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   719
    ec_master_t *master = fsm->slave->master;
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   720
    ec_slave_t *slave = fsm->slave;
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   721
    ec_datagram_t *datagram = fsm->datagram;
618
e4b89c862c43 SII sync managers as array instead of list, removed sync manager
Florian Pose <fp@igh-essen.com>
parents: 615
diff changeset
   722
    unsigned int i;
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   723
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   724
    // slave is now in INIT
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   725
    if (slave->current_state == slave->requested_state) {
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   726
        fsm->state = ec_fsm_slave_state_end; // successful
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   727
        if (master->debug_level) {
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   728
            EC_DBG("Finished configuration of slave %i.\n",
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   729
                   slave->ring_position);
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   730
        }
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
   731
        return;
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   732
    }
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   733
737
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   734
    if (!slave->sii_mailbox_protocols) {
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   735
        // no mailbox protocols supported
731
b13ef712a2d7 Debug statement, if slave does not support mailboxing.
Florian Pose <fp@igh-essen.com>
parents: 713
diff changeset
   736
        if (master->debug_level)
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   737
            EC_DBG("Slave %u does not support mailbox communication.\n",
731
b13ef712a2d7 Debug statement, if slave does not support mailboxing.
Florian Pose <fp@igh-essen.com>
parents: 713
diff changeset
   738
                    slave->ring_position);
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   739
        ec_fsm_slave_conf_enter_preop(fsm);
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   740
        return;
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   741
    }
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   742
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   743
    if (master->debug_level) {
618
e4b89c862c43 SII sync managers as array instead of list, removed sync manager
Florian Pose <fp@igh-essen.com>
parents: 615
diff changeset
   744
        EC_DBG("Configuring mailbox sync managers of slave %i.\n",
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   745
               slave->ring_position);
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   746
    }
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   747
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   748
    if (slave->sii_sync_count >= 2) { // mailbox configuration provided
815
002fe9ec778f Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   749
        ec_datagram_fpwr(datagram, slave->station_address, 0x0800,
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   750
                EC_SYNC_PAGE_SIZE * slave->sii_sync_count);
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   751
        memset(datagram->data, 0x00,
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   752
                EC_SYNC_PAGE_SIZE * slave->sii_sync_count);
737
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   753
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   754
        for (i = 0; i < 2; i++) {
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   755
            ec_sync_config(&slave->sii_syncs[i], slave->sii_syncs[i].length,
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   756
                    datagram->data + EC_SYNC_PAGE_SIZE * i);
737
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   757
        }
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   758
    } else { // no mailbox sync manager configurations provided
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   759
        ec_sync_t sync;
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   760
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   761
        if (master->debug_level)
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   762
            EC_DBG("Slave %u does not provide"
737
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   763
                    " mailbox sync manager configurations.\n",
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   764
                    slave->ring_position);
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   765
815
002fe9ec778f Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   766
        ec_datagram_fpwr(datagram, slave->station_address, 0x0800,
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   767
                EC_SYNC_PAGE_SIZE * 2);
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   768
        memset(datagram->data, 0x00, EC_SYNC_PAGE_SIZE * 2);
737
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   769
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   770
        ec_sync_init(&sync, slave, 0);
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   771
        sync.physical_start_address = slave->sii_rx_mailbox_offset;
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   772
        sync.control_register = 0x26;
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   773
        sync.enable = 1;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   774
        ec_sync_config(&sync, slave->sii_rx_mailbox_size,
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   775
                datagram->data + EC_SYNC_PAGE_SIZE * sync.index);
737
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   776
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   777
        ec_sync_init(&sync, slave, 1);
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   778
        sync.physical_start_address = slave->sii_tx_mailbox_offset;
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   779
        sync.control_register = 0x22;
5a770085161c Master takes mailbox sync manager configurations from EEPROM words
Florian Pose <fp@igh-essen.com>
parents: 734
diff changeset
   780
        sync.enable = 1;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   781
        ec_sync_config(&sync, slave->sii_tx_mailbox_size,
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   782
                datagram->data + EC_SYNC_PAGE_SIZE * sync.index);
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   783
    }
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   784
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   785
    fsm->retries = EC_FSM_RETRIES;
623
4d64368f3a1e Renamed slave configuration states "sync" to "mbox_sync" and "sync2" to
Florian Pose <fp@igh-essen.com>
parents: 620
diff changeset
   786
    fsm->state = ec_fsm_slave_conf_state_mbox_sync;
309
42e69cf31495 Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 308
diff changeset
   787
}
42e69cf31495 Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 308
diff changeset
   788
42e69cf31495 Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 308
diff changeset
   789
/*****************************************************************************/
42e69cf31495 Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 308
diff changeset
   790
42e69cf31495 Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 308
diff changeset
   791
/**
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   792
   Slave configuration state: SYNC.
309
42e69cf31495 Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 308
diff changeset
   793
*/
42e69cf31495 Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 308
diff changeset
   794
623
4d64368f3a1e Renamed slave configuration states "sync" to "mbox_sync" and "sync2" to
Florian Pose <fp@igh-essen.com>
parents: 620
diff changeset
   795
void ec_fsm_slave_conf_state_mbox_sync(ec_fsm_slave_t *fsm /**< slave state machine */)
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   796
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   797
    ec_datagram_t *datagram = fsm->datagram;
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 292
diff changeset
   798
    ec_slave_t *slave = fsm->slave;
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 292
diff changeset
   799
637
d5d04c868e0e Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   800
    if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
d5d04c868e0e Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   801
        return;
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   802
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   803
    if (datagram->state != EC_DATAGRAM_RECEIVED) {
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   804
        fsm->state = ec_fsm_slave_state_error;
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   805
        EC_ERR("Failed to receive sync manager configuration datagram for"
594
07dd2a7df66e Added datagram state to "Failed to receive..." messages.
Florian Pose <fp@igh-essen.com>
parents: 556
diff changeset
   806
               " slave %i (datagram state %i).\n",
07dd2a7df66e Added datagram state to "Failed to receive..." messages.
Florian Pose <fp@igh-essen.com>
parents: 556
diff changeset
   807
               slave->ring_position, datagram->state);
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   808
        return;
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   809
    }
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   810
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   811
    if (datagram->working_counter != 1) {
292
2cf6ae0a2419 Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents: 291
diff changeset
   812
        slave->error_flag = 1;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   813
        fsm->state = ec_fsm_slave_state_error;
713
ae41cadd25b6 Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents: 696
diff changeset
   814
        EC_ERR("Failed to set sync managers of slave %i: ",
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   815
               slave->ring_position);
713
ae41cadd25b6 Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents: 696
diff changeset
   816
        ec_datagram_print_wc_error(datagram);
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   817
        return;
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   818
    }
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   819
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   820
    ec_fsm_slave_conf_enter_preop(fsm);
462
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   821
}
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   822
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   823
/*****************************************************************************/
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   824
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   825
/**
758
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 744
diff changeset
   826
 * Request PREOP state.
462
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   827
 */
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   828
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   829
void ec_fsm_slave_conf_enter_preop(ec_fsm_slave_t *fsm /**< slave state machine */)
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   830
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   831
    fsm->state = ec_fsm_slave_conf_state_preop;
462
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
   832
    ec_fsm_change_start(&fsm->fsm_change, fsm->slave, EC_SLAVE_STATE_PREOP);
434
0180d8277311 Layed out state change state machine.
Florian Pose <fp@igh-essen.com>
parents: 433
diff changeset
   833
    ec_fsm_change_exec(&fsm->fsm_change); // execute immediately
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   834
}
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   835
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   836
/*****************************************************************************/
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   837
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   838
/**
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   839
   Slave configuration state: PREOP.
309
42e69cf31495 Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 308
diff changeset
   840
*/
42e69cf31495 Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 308
diff changeset
   841
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   842
void ec_fsm_slave_conf_state_preop(ec_fsm_slave_t *fsm /**< slave state machine */)
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   843
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   844
    ec_slave_t *slave = fsm->slave;
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   845
    ec_master_t *master = fsm->slave->master;
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   846
435
779a18d12e6c Removed state machine running() methods.
Florian Pose <fp@igh-essen.com>
parents: 434
diff changeset
   847
    if (ec_fsm_change_exec(&fsm->fsm_change)) return;
434
0180d8277311 Layed out state change state machine.
Florian Pose <fp@igh-essen.com>
parents: 433
diff changeset
   848
0180d8277311 Layed out state change state machine.
Florian Pose <fp@igh-essen.com>
parents: 433
diff changeset
   849
    if (!ec_fsm_change_success(&fsm->fsm_change)) {
738
880c6153101f Improved handling for spontaneous AL state changes.
Florian Pose <fp@igh-essen.com>
parents: 737
diff changeset
   850
        if (!fsm->fsm_change.spontaneous_change)
880c6153101f Improved handling for spontaneous AL state changes.
Florian Pose <fp@igh-essen.com>
parents: 737
diff changeset
   851
            slave->error_flag = 1;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   852
        fsm->state = ec_fsm_slave_state_error;
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
   853
        return;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
   854
    }
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
   855
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   856
    // slave is now in PREOP
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   857
    slave->jiffies_preop = fsm->datagram->jiffies_received;
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   858
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   859
    if (master->debug_level) {
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   860
        EC_DBG("Slave %i is now in PREOP.\n", slave->ring_position);
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   861
    }
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
   862
419
cf724fc82a00 Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents: 411
diff changeset
   863
    if (slave->current_state == slave->requested_state) {
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
   864
        fsm->state = ec_fsm_slave_state_end; // successful
419
cf724fc82a00 Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents: 411
diff changeset
   865
        if (master->debug_level) {
cf724fc82a00 Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents: 411
diff changeset
   866
            EC_DBG("Finished configuration of slave %i.\n",
cf724fc82a00 Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents: 411
diff changeset
   867
                   slave->ring_position);
cf724fc82a00 Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents: 411
diff changeset
   868
        }
cf724fc82a00 Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents: 411
diff changeset
   869
        return;
cf724fc82a00 Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents: 411
diff changeset
   870
    }
cf724fc82a00 Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents: 411
diff changeset
   871
795
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   872
    ec_fsm_slave_conf_enter_sdo_conf(fsm);
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   873
}
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   874
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   875
/*****************************************************************************/
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   876
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   877
/**
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
   878
 * Check for Sdo configurations to be applied.
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   879
 */
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   880
795
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   881
void ec_fsm_slave_conf_enter_sdo_conf(ec_fsm_slave_t *fsm /**< slave state machine */)
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   882
{
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   883
    ec_slave_t *slave = fsm->slave;
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   884
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   885
    if (!slave->config) {
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   886
        EC_DBG("Slave %u is not configured.\n", slave->ring_position);
813
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 802
diff changeset
   887
        ec_fsm_slave_conf_enter_safeop(fsm);
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   888
        return;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   889
    }
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   890
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   891
    // No CoE configuration to be applied?
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
   892
    if (list_empty(&slave->config->sdo_configs)) { // skip Sdo configuration
795
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   893
        ec_fsm_slave_conf_enter_mapping(fsm);
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   894
        return;
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   895
    }
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   896
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
   897
    // start Sdo configuration
795
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   898
    fsm->state = ec_fsm_slave_conf_state_sdo_conf;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   899
    fsm->sdodata =
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   900
        list_entry(fsm->slave->config->sdo_configs.next, ec_sdo_data_t, list);
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   901
    ec_fsm_coe_download(&fsm->fsm_coe, fsm->slave, fsm->sdodata);
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   902
    ec_fsm_coe_exec(&fsm->fsm_coe); // execute immediately
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   903
}
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   904
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   905
/*****************************************************************************/
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   906
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   907
/**
795
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   908
   Slave configuration state: SDO_CONF.
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   909
*/
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   910
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   911
void ec_fsm_slave_conf_state_sdo_conf(
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   912
        ec_fsm_slave_t *fsm /**< slave state machine */
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   913
        )
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   914
{
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   915
    if (ec_fsm_coe_exec(&fsm->fsm_coe)) return;
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   916
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   917
    if (!ec_fsm_coe_success(&fsm->fsm_coe)) {
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
   918
        EC_ERR("Sdo configuration failed for slave %u.\n",
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   919
                fsm->slave->ring_position);
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   920
        fsm->slave->error_flag = 1;
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   921
        fsm->state = ec_fsm_slave_state_error;
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   922
        return;
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   923
    }
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   924
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
   925
    // Another Sdo to configure?
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   926
    if (fsm->sdodata->list.next != &fsm->slave->config->sdo_configs) {
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   927
        fsm->sdodata =
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
   928
            list_entry(fsm->sdodata->list.next, ec_sdo_data_t, list);
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   929
        ec_fsm_coe_download(&fsm->fsm_coe, fsm->slave, fsm->sdodata);
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   930
        ec_fsm_coe_exec(&fsm->fsm_coe); // execute immediately
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   931
        return;
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   932
    }
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   933
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
   934
    // All Sdos are now configured.
795
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   935
    ec_fsm_slave_conf_enter_mapping(fsm);
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   936
}
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   937
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   938
/*****************************************************************************/
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   939
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   940
/**
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
   941
 * Check for Pdo mappings to be applied.
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   942
 */
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   943
795
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   944
void ec_fsm_slave_conf_enter_mapping(
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   945
        ec_fsm_slave_t *fsm /**< slave state machine */
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   946
        )
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   947
{
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
   948
    // start configuring Pdo mapping
795
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   949
    fsm->state = ec_fsm_slave_conf_state_mapping;
802
b947d0b09f9a Renamed ec_fsm_mapping_t to ec_fsm_pdo_mapping_t.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   950
    ec_fsm_pdo_mapping_start(&fsm->fsm_pdo_map, fsm->slave);
b947d0b09f9a Renamed ec_fsm_mapping_t to ec_fsm_pdo_mapping_t.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   951
    ec_fsm_pdo_mapping_exec(&fsm->fsm_pdo_map); // execute immediately
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   952
}
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   953
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   954
/*****************************************************************************/
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   955
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   956
/**
795
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   957
   Slave configuration state: MAPPING.
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   958
*/
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   959
c695e53940d4 Renamed a few configuration states.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   960
void ec_fsm_slave_conf_state_mapping(
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   961
        ec_fsm_slave_t *fsm /**< slave state machine */
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   962
        )
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   963
{
802
b947d0b09f9a Renamed ec_fsm_mapping_t to ec_fsm_pdo_mapping_t.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   964
    if (ec_fsm_pdo_mapping_exec(&fsm->fsm_pdo_map)) return;
b947d0b09f9a Renamed ec_fsm_mapping_t to ec_fsm_pdo_mapping_t.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   965
b947d0b09f9a Renamed ec_fsm_mapping_t to ec_fsm_pdo_mapping_t.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   966
    if (!ec_fsm_pdo_mapping_success(&fsm->fsm_pdo_map)) {
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
   967
        EC_ERR("Pdo mapping configuration failed for slave %u.\n",
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   968
                fsm->slave->ring_position);
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   969
        fsm->slave->error_flag = 1;
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   970
        fsm->state = ec_fsm_slave_state_error;
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   971
        return;
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   972
    }
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   973
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   974
    // Start Pdo configuration
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   975
    fsm->state = ec_fsm_slave_conf_state_pdo_conf;
802
b947d0b09f9a Renamed ec_fsm_mapping_t to ec_fsm_pdo_mapping_t.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   976
    ec_fsm_pdo_config_start(&fsm->fsm_pdo_conf, fsm->slave);
b947d0b09f9a Renamed ec_fsm_mapping_t to ec_fsm_pdo_mapping_t.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   977
    ec_fsm_pdo_config_exec(&fsm->fsm_pdo_conf); // execute immediately
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   978
}
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   979
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   980
/*****************************************************************************/
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   981
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   982
/**
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   983
   Slave configuration state: PDO_CONF.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   984
*/
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   985
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   986
void ec_fsm_slave_conf_state_pdo_conf(
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   987
        ec_fsm_slave_t *fsm /**< slave state machine */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   988
        )
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   989
{
802
b947d0b09f9a Renamed ec_fsm_mapping_t to ec_fsm_pdo_mapping_t.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   990
    if (ec_fsm_pdo_config_exec(&fsm->fsm_pdo_conf)) return;
b947d0b09f9a Renamed ec_fsm_mapping_t to ec_fsm_pdo_mapping_t.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   991
b947d0b09f9a Renamed ec_fsm_mapping_t to ec_fsm_pdo_mapping_t.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   992
    if (!ec_fsm_pdo_config_success(&fsm->fsm_pdo_conf)) {
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   993
        EC_ERR("Pdo configuration failed for slave %u.\n",
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   994
                fsm->slave->ring_position);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   995
        fsm->slave->error_flag = 1;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   996
        fsm->state = ec_fsm_slave_state_error;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   997
        return;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   998
    }
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 795
diff changeset
   999
623
4d64368f3a1e Renamed slave configuration states "sync" to "mbox_sync" and "sync2" to
Florian Pose <fp@igh-essen.com>
parents: 620
diff changeset
  1000
    ec_fsm_slave_conf_enter_pdo_sync(fsm);
4d64368f3a1e Renamed slave configuration states "sync" to "mbox_sync" and "sync2" to
Florian Pose <fp@igh-essen.com>
parents: 620
diff changeset
  1001
}
4d64368f3a1e Renamed slave configuration states "sync" to "mbox_sync" and "sync2" to
Florian Pose <fp@igh-essen.com>
parents: 620
diff changeset
  1002
4d64368f3a1e Renamed slave configuration states "sync" to "mbox_sync" and "sync2" to
Florian Pose <fp@igh-essen.com>
parents: 620
diff changeset
  1003
/*****************************************************************************/
4d64368f3a1e Renamed slave configuration states "sync" to "mbox_sync" and "sync2" to
Florian Pose <fp@igh-essen.com>
parents: 620
diff changeset
  1004
4d64368f3a1e Renamed slave configuration states "sync" to "mbox_sync" and "sync2" to
Florian Pose <fp@igh-essen.com>
parents: 620
diff changeset
  1005
/**
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
  1006
 * Check for Pdo sync managers to be configured.
628
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents: 623
diff changeset
  1007
 */
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents: 623
diff changeset
  1008
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents: 623
diff changeset
  1009
void ec_fsm_slave_conf_enter_pdo_sync(
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents: 623
diff changeset
  1010
        ec_fsm_slave_t *fsm /**< slave state machine */
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents: 623
diff changeset
  1011
        )
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1012
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1013
    ec_slave_t *slave = fsm->slave;
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1014
    ec_datagram_t *datagram = fsm->datagram;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1015
    unsigned int i, offset, num_syncs;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1016
    const ec_sync_t *sync;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1017
    ec_direction_t dir;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1018
    uint16_t size;
618
e4b89c862c43 SII sync managers as array instead of list, removed sync manager
Florian Pose <fp@igh-essen.com>
parents: 615
diff changeset
  1019
e4b89c862c43 SII sync managers as array instead of list, removed sync manager
Florian Pose <fp@igh-essen.com>
parents: 615
diff changeset
  1020
    if (!slave->sii_sync_count) {
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1021
        ec_fsm_slave_conf_enter_fmmu(fsm);
478
322fab6b085b Fix: Configuration of process data sync managers now in PREOP.
Florian Pose <fp@igh-essen.com>
parents: 475
diff changeset
  1022
        return;
322fab6b085b Fix: Configuration of process data sync managers now in PREOP.
Florian Pose <fp@igh-essen.com>
parents: 475
diff changeset
  1023
    }
322fab6b085b Fix: Configuration of process data sync managers now in PREOP.
Florian Pose <fp@igh-essen.com>
parents: 475
diff changeset
  1024
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1025
    if (slave->sii_mailbox_protocols) {
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1026
        offset = 2; // slave has mailboxes
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1027
    } else {
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1028
        offset = 0;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1029
    }
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1030
    num_syncs = slave->sii_sync_count - offset;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1031
478
322fab6b085b Fix: Configuration of process data sync managers now in PREOP.
Florian Pose <fp@igh-essen.com>
parents: 475
diff changeset
  1032
    // configure sync managers for process data
815
002fe9ec778f Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
  1033
    ec_datagram_fpwr(datagram, slave->station_address,
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1034
            0x0800 + EC_SYNC_PAGE_SIZE * offset,
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1035
            EC_SYNC_PAGE_SIZE * num_syncs);
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1036
    memset(datagram->data, 0x00, EC_SYNC_PAGE_SIZE * num_syncs);
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1037
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1038
    for (i = 0; i < num_syncs; i++) {
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1039
        sync = &slave->sii_syncs[i + offset];
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1040
        dir = ec_sync_direction(sync);
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1041
        size = ec_pdo_mapping_total_size(&slave->config->mapping[dir]);
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1042
        ec_sync_config(sync, size, datagram->data + EC_SYNC_PAGE_SIZE * i);
478
322fab6b085b Fix: Configuration of process data sync managers now in PREOP.
Florian Pose <fp@igh-essen.com>
parents: 475
diff changeset
  1043
    }
322fab6b085b Fix: Configuration of process data sync managers now in PREOP.
Florian Pose <fp@igh-essen.com>
parents: 475
diff changeset
  1044
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
  1045
    fsm->retries = EC_FSM_RETRIES;
623
4d64368f3a1e Renamed slave configuration states "sync" to "mbox_sync" and "sync2" to
Florian Pose <fp@igh-essen.com>
parents: 620
diff changeset
  1046
    fsm->state = ec_fsm_slave_conf_state_pdo_sync;
478
322fab6b085b Fix: Configuration of process data sync managers now in PREOP.
Florian Pose <fp@igh-essen.com>
parents: 475
diff changeset
  1047
}
322fab6b085b Fix: Configuration of process data sync managers now in PREOP.
Florian Pose <fp@igh-essen.com>
parents: 475
diff changeset
  1048
322fab6b085b Fix: Configuration of process data sync managers now in PREOP.
Florian Pose <fp@igh-essen.com>
parents: 475
diff changeset
  1049
/*****************************************************************************/
322fab6b085b Fix: Configuration of process data sync managers now in PREOP.
Florian Pose <fp@igh-essen.com>
parents: 475
diff changeset
  1050
322fab6b085b Fix: Configuration of process data sync managers now in PREOP.
Florian Pose <fp@igh-essen.com>
parents: 475
diff changeset
  1051
/**
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
  1052
 * Configure Pdo sync managers.
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
  1053
 */
478
322fab6b085b Fix: Configuration of process data sync managers now in PREOP.
Florian Pose <fp@igh-essen.com>
parents: 475
diff changeset
  1054
623
4d64368f3a1e Renamed slave configuration states "sync" to "mbox_sync" and "sync2" to
Florian Pose <fp@igh-essen.com>
parents: 620
diff changeset
  1055
void ec_fsm_slave_conf_state_pdo_sync(ec_fsm_slave_t *fsm /**< slave state machine */)
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1056
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1057
    ec_datagram_t *datagram = fsm->datagram;
478
322fab6b085b Fix: Configuration of process data sync managers now in PREOP.
Florian Pose <fp@igh-essen.com>
parents: 475
diff changeset
  1058
    ec_slave_t *slave = fsm->slave;
322fab6b085b Fix: Configuration of process data sync managers now in PREOP.
Florian Pose <fp@igh-essen.com>
parents: 475
diff changeset
  1059
637
d5d04c868e0e Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
  1060
    if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
d5d04c868e0e Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
  1061
        return;
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
  1062
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
  1063
    if (datagram->state != EC_DATAGRAM_RECEIVED) {
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1064
        fsm->state = ec_fsm_slave_state_error;
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
  1065
        EC_ERR("Failed to receive process data sync manager configuration"
594
07dd2a7df66e Added datagram state to "Failed to receive..." messages.
Florian Pose <fp@igh-essen.com>
parents: 556
diff changeset
  1066
               " datagram for slave %i (datagram state %i).\n",
07dd2a7df66e Added datagram state to "Failed to receive..." messages.
Florian Pose <fp@igh-essen.com>
parents: 556
diff changeset
  1067
               slave->ring_position, datagram->state);
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
  1068
        return;
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
  1069
    }
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
  1070
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
  1071
    if (datagram->working_counter != 1) {
478
322fab6b085b Fix: Configuration of process data sync managers now in PREOP.
Florian Pose <fp@igh-essen.com>
parents: 475
diff changeset
  1072
        slave->error_flag = 1;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1073
        fsm->state = ec_fsm_slave_state_error;
713
ae41cadd25b6 Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents: 696
diff changeset
  1074
        EC_ERR("Failed to set process data sync managers of slave %i: ",
ae41cadd25b6 Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents: 696
diff changeset
  1075
                slave->ring_position);
ae41cadd25b6 Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents: 696
diff changeset
  1076
        ec_datagram_print_wc_error(datagram);
478
322fab6b085b Fix: Configuration of process data sync managers now in PREOP.
Florian Pose <fp@igh-essen.com>
parents: 475
diff changeset
  1077
        return;
322fab6b085b Fix: Configuration of process data sync managers now in PREOP.
Florian Pose <fp@igh-essen.com>
parents: 475
diff changeset
  1078
    }
322fab6b085b Fix: Configuration of process data sync managers now in PREOP.
Florian Pose <fp@igh-essen.com>
parents: 475
diff changeset
  1079
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1080
    ec_fsm_slave_conf_enter_fmmu(fsm);
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1081
}
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1082
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1083
/*****************************************************************************/
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1084
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1085
/**
758
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 744
diff changeset
  1086
 * Check for FMMUs to be configured.
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 744
diff changeset
  1087
 */
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1088
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1089
void ec_fsm_slave_conf_enter_fmmu(ec_fsm_slave_t *fsm /**< slave state machine */)
478
322fab6b085b Fix: Configuration of process data sync managers now in PREOP.
Florian Pose <fp@igh-essen.com>
parents: 475
diff changeset
  1090
{
322fab6b085b Fix: Configuration of process data sync managers now in PREOP.
Florian Pose <fp@igh-essen.com>
parents: 475
diff changeset
  1091
    ec_slave_t *slave = fsm->slave;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1092
    ec_datagram_t *datagram = fsm->datagram;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1093
    unsigned int i;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1094
    const ec_fmmu_config_t *fmmu;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1095
    const ec_sync_t *sync;
478
322fab6b085b Fix: Configuration of process data sync managers now in PREOP.
Florian Pose <fp@igh-essen.com>
parents: 475
diff changeset
  1096
823
24096a495dd8 Check for FMMU limits.
Florian Pose <fp@igh-essen.com>
parents: 822
diff changeset
  1097
    if (slave->base_fmmu_count < slave->config->used_fmmus) {
24096a495dd8 Check for FMMU limits.
Florian Pose <fp@igh-essen.com>
parents: 822
diff changeset
  1098
        slave->error_flag = 1;
24096a495dd8 Check for FMMU limits.
Florian Pose <fp@igh-essen.com>
parents: 822
diff changeset
  1099
        fsm->state = ec_fsm_slave_state_error;
24096a495dd8 Check for FMMU limits.
Florian Pose <fp@igh-essen.com>
parents: 822
diff changeset
  1100
        EC_ERR("Slave %u has less FMMUs (%u) than requested (%u).\n",
24096a495dd8 Check for FMMU limits.
Florian Pose <fp@igh-essen.com>
parents: 822
diff changeset
  1101
                slave->ring_position, slave->base_fmmu_count,
24096a495dd8 Check for FMMU limits.
Florian Pose <fp@igh-essen.com>
parents: 822
diff changeset
  1102
                slave->config->used_fmmus);
24096a495dd8 Check for FMMU limits.
Florian Pose <fp@igh-essen.com>
parents: 822
diff changeset
  1103
        return;
24096a495dd8 Check for FMMU limits.
Florian Pose <fp@igh-essen.com>
parents: 822
diff changeset
  1104
    }
24096a495dd8 Check for FMMU limits.
Florian Pose <fp@igh-essen.com>
parents: 822
diff changeset
  1105
419
cf724fc82a00 Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents: 411
diff changeset
  1106
    if (!slave->base_fmmu_count) { // skip FMMU configuration
813
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 802
diff changeset
  1107
        ec_fsm_slave_conf_enter_safeop(fsm);
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
  1108
        return;
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
  1109
    }
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
  1110
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
  1111
    // configure FMMUs
815
002fe9ec778f Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
  1112
    ec_datagram_fpwr(datagram, slave->station_address,
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1113
                     0x0600, EC_FMMU_PAGE_SIZE * slave->base_fmmu_count);
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1114
    memset(datagram->data, 0x00, EC_FMMU_PAGE_SIZE * slave->base_fmmu_count);
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1115
    for (i = 0; i < slave->config->used_fmmus; i++) {
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1116
        fmmu = &slave->config->fmmu_configs[i];
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1117
        if (!(sync = ec_slave_get_pdo_sync(slave, fmmu->dir))) {
822
21c86d97c587 Fixed missing slave_error flag.
Florian Pose <fp@igh-essen.com>
parents: 815
diff changeset
  1118
            slave->error_flag = 1;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1119
            fsm->state = ec_fsm_slave_state_error;
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
  1120
            EC_ERR("Failed to determine Pdo sync manager for FMMU on slave"
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1121
                    " %u!\n", slave->ring_position);
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1122
            return;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1123
        }
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1124
        ec_fmmu_config_page(fmmu, sync,
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 771
diff changeset
  1125
                datagram->data + EC_FMMU_PAGE_SIZE * i);
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 292
diff changeset
  1126
    }
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 292
diff changeset
  1127
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
  1128
    fsm->retries = EC_FSM_RETRIES;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1129
    fsm->state = ec_fsm_slave_conf_state_fmmu;
309
42e69cf31495 Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 308
diff changeset
  1130
}
42e69cf31495 Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 308
diff changeset
  1131
42e69cf31495 Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 308
diff changeset
  1132
/*****************************************************************************/
42e69cf31495 Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 308
diff changeset
  1133
42e69cf31495 Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 308
diff changeset
  1134
/**
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
  1135
   Slave configuration state: FMMU.
309
42e69cf31495 Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 308
diff changeset
  1136
*/
42e69cf31495 Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 308
diff changeset
  1137
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1138
void ec_fsm_slave_conf_state_fmmu(ec_fsm_slave_t *fsm /**< slave state machine */)
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1139
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1140
    ec_datagram_t *datagram = fsm->datagram;
419
cf724fc82a00 Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents: 411
diff changeset
  1141
    ec_slave_t *slave = fsm->slave;
309
42e69cf31495 Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 308
diff changeset
  1142
637
d5d04c868e0e Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
  1143
    if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
d5d04c868e0e Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
  1144
        return;
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
  1145
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
  1146
    if (datagram->state != EC_DATAGRAM_RECEIVED) {
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1147
        fsm->state = ec_fsm_slave_state_error;
594
07dd2a7df66e Added datagram state to "Failed to receive..." messages.
Florian Pose <fp@igh-essen.com>
parents: 556
diff changeset
  1148
        EC_ERR("Failed to receive FMMUs datagram for slave %i"
07dd2a7df66e Added datagram state to "Failed to receive..." messages.
Florian Pose <fp@igh-essen.com>
parents: 556
diff changeset
  1149
                " (datagram state %i).\n",
615
cde783147040 Removed unnecessary edge in slave configuration FSM graph.
Florian Pose <fp@igh-essen.com>
parents: 594
diff changeset
  1150
               slave->ring_position, datagram->state);
505
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
  1151
        return;
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
  1152
    }
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
  1153
bc443ca0077f State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
  1154
    if (datagram->working_counter != 1) {
615
cde783147040 Removed unnecessary edge in slave configuration FSM graph.
Florian Pose <fp@igh-essen.com>
parents: 594
diff changeset
  1155
        slave->error_flag = 1;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1156
        fsm->state = ec_fsm_slave_state_error;
713
ae41cadd25b6 Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents: 696
diff changeset
  1157
        EC_ERR("Failed to set FMMUs of slave %i: ",
615
cde783147040 Removed unnecessary edge in slave configuration FSM graph.
Florian Pose <fp@igh-essen.com>
parents: 594
diff changeset
  1158
               slave->ring_position);
713
ae41cadd25b6 Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents: 696
diff changeset
  1159
        ec_datagram_print_wc_error(datagram);
615
cde783147040 Removed unnecessary edge in slave configuration FSM graph.
Florian Pose <fp@igh-essen.com>
parents: 594
diff changeset
  1160
        return;
cde783147040 Removed unnecessary edge in slave configuration FSM graph.
Florian Pose <fp@igh-essen.com>
parents: 594
diff changeset
  1161
    }
cde783147040 Removed unnecessary edge in slave configuration FSM graph.
Florian Pose <fp@igh-essen.com>
parents: 594
diff changeset
  1162
813
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 802
diff changeset
  1163
    ec_fsm_slave_conf_enter_safeop(fsm);
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 802
diff changeset
  1164
}
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 802
diff changeset
  1165
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 802
diff changeset
  1166
/*****************************************************************************/
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 802
diff changeset
  1167
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 802
diff changeset
  1168
/**
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 802
diff changeset
  1169
 * Request SAFEOP state.
462
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
  1170
 */
e6fac0c8bc92 New state in slaveconf FSM: Clear FMMU configurations after INIT.
Florian Pose <fp@igh-essen.com>
parents: 461
diff changeset
  1171
813
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 802
diff changeset
  1172
void ec_fsm_slave_conf_enter_safeop(ec_fsm_slave_t *fsm /**< slave state machine */)
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 802
diff changeset
  1173
{
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 802
diff changeset
  1174
    fsm->state = ec_fsm_slave_conf_state_safeop;
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 802
diff changeset
  1175
    ec_fsm_change_start(&fsm->fsm_change, fsm->slave, EC_SLAVE_STATE_SAFEOP);
434
0180d8277311 Layed out state change state machine.
Florian Pose <fp@igh-essen.com>
parents: 433
diff changeset
  1176
    ec_fsm_change_exec(&fsm->fsm_change); // execute immediately
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
  1177
}
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
  1178
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
  1179
/*****************************************************************************/
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
  1180
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
  1181
/**
813
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 802
diff changeset
  1182
   Slave configuration state: SAFEOP.
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 802
diff changeset
  1183
*/
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 802
diff changeset
  1184
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 802
diff changeset
  1185
void ec_fsm_slave_conf_state_safeop(ec_fsm_slave_t *fsm /**< slave state machine */)
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1186
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1187
    ec_master_t *master = fsm->slave->master;
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
  1188
    ec_slave_t *slave = fsm->slave;
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
  1189
435
779a18d12e6c Removed state machine running() methods.
Florian Pose <fp@igh-essen.com>
parents: 434
diff changeset
  1190
    if (ec_fsm_change_exec(&fsm->fsm_change)) return;
434
0180d8277311 Layed out state change state machine.
Florian Pose <fp@igh-essen.com>
parents: 433
diff changeset
  1191
0180d8277311 Layed out state change state machine.
Florian Pose <fp@igh-essen.com>
parents: 433
diff changeset
  1192
    if (!ec_fsm_change_success(&fsm->fsm_change)) {
738
880c6153101f Improved handling for spontaneous AL state changes.
Florian Pose <fp@igh-essen.com>
parents: 737
diff changeset
  1193
        if (!fsm->fsm_change.spontaneous_change)
880c6153101f Improved handling for spontaneous AL state changes.
Florian Pose <fp@igh-essen.com>
parents: 737
diff changeset
  1194
            fsm->slave->error_flag = 1;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1195
        fsm->state = ec_fsm_slave_state_error;
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
  1196
        return;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
  1197
    }
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
  1198
813
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 802
diff changeset
  1199
    // slave is now in SAFEOP
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
  1200
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
  1201
    if (master->debug_level) {
813
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 802
diff changeset
  1202
        EC_DBG("Slave %i is now in SAFEOP.\n", slave->ring_position);
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
  1203
    }
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
  1204
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
  1205
    if (fsm->slave->current_state == fsm->slave->requested_state) {
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1206
        fsm->state = ec_fsm_slave_state_end; // successful
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
  1207
        if (master->debug_level) {
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
  1208
            EC_DBG("Finished configuration of slave %i.\n",
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
  1209
                   slave->ring_position);
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
  1210
        }
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
  1211
        return;
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
  1212
    }
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
  1213
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
  1214
    // set state to OP
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1215
    fsm->state = ec_fsm_slave_conf_state_op;
454
25cc4a3b9e0a State acknowledgement in master state machine.
Florian Pose <fp@igh-essen.com>
parents: 448
diff changeset
  1216
    ec_fsm_change_start(&fsm->fsm_change, slave, EC_SLAVE_STATE_OP);
434
0180d8277311 Layed out state change state machine.
Florian Pose <fp@igh-essen.com>
parents: 433
diff changeset
  1217
    ec_fsm_change_exec(&fsm->fsm_change); // execute immediately
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
  1218
}
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
  1219
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
  1220
/*****************************************************************************/
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
  1221
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
  1222
/**
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
  1223
   Slave configuration state: OP
309
42e69cf31495 Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 308
diff changeset
  1224
*/
42e69cf31495 Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents: 308
diff changeset
  1225
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1226
void ec_fsm_slave_conf_state_op(ec_fsm_slave_t *fsm /**< slave state machine */)
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1227
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1228
    ec_master_t *master = fsm->slave->master;
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
  1229
    ec_slave_t *slave = fsm->slave;
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
  1230
435
779a18d12e6c Removed state machine running() methods.
Florian Pose <fp@igh-essen.com>
parents: 434
diff changeset
  1231
    if (ec_fsm_change_exec(&fsm->fsm_change)) return;
434
0180d8277311 Layed out state change state machine.
Florian Pose <fp@igh-essen.com>
parents: 433
diff changeset
  1232
0180d8277311 Layed out state change state machine.
Florian Pose <fp@igh-essen.com>
parents: 433
diff changeset
  1233
    if (!ec_fsm_change_success(&fsm->fsm_change)) {
738
880c6153101f Improved handling for spontaneous AL state changes.
Florian Pose <fp@igh-essen.com>
parents: 737
diff changeset
  1234
        if (!fsm->fsm_change.spontaneous_change)
880c6153101f Improved handling for spontaneous AL state changes.
Florian Pose <fp@igh-essen.com>
parents: 737
diff changeset
  1235
            slave->error_flag = 1;
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1236
        fsm->state = ec_fsm_slave_state_error;
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
  1237
        return;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
  1238
    }
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
  1239
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
  1240
    // slave is now in OP
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
  1241
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
  1242
    if (master->debug_level) {
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
  1243
        EC_DBG("Slave %i is now in OP.\n", slave->ring_position);
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
  1244
        EC_DBG("Finished configuration of slave %i.\n", slave->ring_position);
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
  1245
    }
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 407
diff changeset
  1246
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1247
    fsm->state = ec_fsm_slave_state_end; // successful
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1248
}
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1249
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1250
/******************************************************************************
329
d004349777fc SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
  1251
 *  Common state functions
d004349777fc SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
  1252
 *****************************************************************************/
286
f3352378b4d4 Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
  1253
f3352378b4d4 Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
  1254
/**
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
  1255
   State: ERROR.
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
  1256
*/
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
  1257
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1258
void ec_fsm_slave_state_error(ec_fsm_slave_t *fsm /**< slave state machine */)
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
  1259
{
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
  1260
}
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
  1261
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
  1262
/*****************************************************************************/
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
  1263
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
  1264
/**
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
  1265
   State: END.
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
  1266
*/
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 312
diff changeset
  1267
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1268
void ec_fsm_slave_state_end(ec_fsm_slave_t *fsm /**< slave state machine */)
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1269
{
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1270
}
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1271
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 523
diff changeset
  1272
/*****************************************************************************/