master/fsm_coe_map.c
author Florian Pose <fp@igh-essen.com>
Thu, 19 Jun 2008 10:18:58 +0000
changeset 1040 d2527675cdd5
parent 1036 dc2008bc8113
child 1044 0d73427db362
permissions -rw-r--r--
Disable use of CPU timestamp counter by default.
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
768
b709149d5bba Added missing svn properties.
Florian Pose <fp@igh-essen.com>
parents: 767
diff changeset
     3
 *  $Id$
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 *  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *  This file is part of the IgH EtherCAT Master.
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
 *  and/or modify it under the terms of the GNU General Public License
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
 *  as published by the Free Software Foundation; either version 2 of the
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
 *  License, or (at your option) any later version.
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
 *
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
 *  The IgH EtherCAT Master is distributed in the hope that it will be
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
 *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
 *  GNU General Public License for more details.
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
 *
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
 *  You should have received a copy of the GNU General Public License
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
 *  along with the IgH EtherCAT Master; if not, write to the Free Software
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
 *
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
 *  The right to use EtherCAT Technology is granted and comes free of
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
 *  charge under condition of compatibility of product made by
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
 *  Licensee. People intending to distribute/sell products based on the
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
 *  code, have to sign an agreement to guarantee that products using
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
 *  software based on IgH EtherCAT master stay compatible with the actual
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 *  EtherCAT specification (which are released themselves as an open
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
 *  standard) as the (only) precondition to have the right to use EtherCAT
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
 *  Technology, IP and trade marks.
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
 *
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
 *****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
/**
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
   \file
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
    36
   EtherCAT Pdo information state machines.
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
*/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
/*****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
#include "globals.h"
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
#include "master.h"
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
#include "mailbox.h"
847
92266462d411 Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
    44
#include "sdo_request.h"
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
#include "fsm_coe_map.h"
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
/*****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
void ec_fsm_coe_map_state_start(ec_fsm_coe_map_t *);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
void ec_fsm_coe_map_state_pdo_count(ec_fsm_coe_map_t *);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
void ec_fsm_coe_map_state_pdo(ec_fsm_coe_map_t *);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
void ec_fsm_coe_map_state_pdo_entry_count(ec_fsm_coe_map_t *);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
void ec_fsm_coe_map_state_pdo_entry(ec_fsm_coe_map_t *);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
void ec_fsm_coe_map_state_end(ec_fsm_coe_map_t *);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
void ec_fsm_coe_map_state_error(ec_fsm_coe_map_t *);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    58
void ec_fsm_coe_map_action_next_dir(ec_fsm_coe_map_t *);
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
void ec_fsm_coe_map_action_next_pdo(ec_fsm_coe_map_t *);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
void ec_fsm_coe_map_action_next_pdo_entry(ec_fsm_coe_map_t *);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
/*****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
/**
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
   Constructor.
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
*/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
void ec_fsm_coe_map_init(
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
        ec_fsm_coe_map_t *fsm, /**< finite state machine */
758
8fa6f825eb7d Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents: 751
diff changeset
    70
        ec_fsm_coe_t *fsm_coe /**< CoE state machine to use */
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
        )
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
{
852
ab439cbc7a81 Separated ec_sdo_request_init() and ec_sdo_request_read().
Florian Pose <fp@igh-essen.com>
parents: 849
diff changeset
    73
    fsm->fsm_coe = fsm_coe;
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
    fsm->state = NULL;
852
ab439cbc7a81 Separated ec_sdo_request_init() and ec_sdo_request_read().
Florian Pose <fp@igh-essen.com>
parents: 849
diff changeset
    75
    ec_sdo_request_init(&fsm->request);
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
    76
    ec_pdo_list_init(&fsm->pdos);
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
}
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
/*****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
/**
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
   Destructor.
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
*/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
void ec_fsm_coe_map_clear(ec_fsm_coe_map_t *fsm /**< finite state machine */)
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
{
852
ab439cbc7a81 Separated ec_sdo_request_init() and ec_sdo_request_read().
Florian Pose <fp@igh-essen.com>
parents: 849
diff changeset
    87
    ec_sdo_request_clear(&fsm->request);
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
    88
    ec_pdo_list_clear(&fsm->pdos);
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
}
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
/*****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
/**
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
    94
   Starts to upload an Sdo from a slave.
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
*/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
void ec_fsm_coe_map_start(
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
        ec_fsm_coe_map_t *fsm, /**< finite state machine */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
        ec_slave_t *slave /**< EtherCAT slave */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
        )
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
{
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
    fsm->slave = slave;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
    fsm->state = ec_fsm_coe_map_state_start;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
}
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
/*****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
/**
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
   Executes the current state of the state machine.
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
   \return false, if state machine has terminated
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
*/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
int ec_fsm_coe_map_exec(ec_fsm_coe_map_t *fsm /**< finite state machine */)
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
{
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
    fsm->state(fsm);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
    return fsm->state != ec_fsm_coe_map_state_end
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
        && fsm->state != ec_fsm_coe_map_state_error;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
}
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
/*****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
/**
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
   Returns, if the state machine terminated with success.
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
   \return non-zero if successful.
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
*/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
int ec_fsm_coe_map_success(ec_fsm_coe_map_t *fsm /**< Finite state machine */)
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
{
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
    return fsm->state == ec_fsm_coe_map_state_end;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
}
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
/******************************************************************************
751
41a5c537b76d Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 749
diff changeset
   134
 *  state functions
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
 *****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
/**
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   138
 * Start reading Pdo assignment.
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
 */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
751
41a5c537b76d Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 749
diff changeset
   141
void ec_fsm_coe_map_state_start(
41a5c537b76d Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 749
diff changeset
   142
        ec_fsm_coe_map_t *fsm /**< finite state machine */
41a5c537b76d Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 749
diff changeset
   143
        )
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
{
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   145
    // read Pdo assignment for first direction
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   146
    fsm->dir = (ec_direction_t) -1; // next is EC_DIR_OUTPUT
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   147
    ec_fsm_coe_map_action_next_dir(fsm);
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   148
}
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   149
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   150
/*****************************************************************************/
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   151
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   152
/**
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   153
 * Read Pdo assignment of next direction manager.
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   154
 */
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   155
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   156
void ec_fsm_coe_map_action_next_dir(
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
        ec_fsm_coe_map_t *fsm /**< finite state machine */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
        )
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
{
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
    ec_slave_t *slave = fsm->slave;
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   161
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   162
    fsm->dir++;
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   163
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   164
    if (slave->master->debug_level)
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   165
        EC_DBG("Processing dir %u of slave %u.\n",
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   166
                fsm->dir, slave->ring_position);
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   167
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   168
    for (; fsm->dir <= EC_DIR_INPUT; fsm->dir++) {
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   169
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   170
        if (!(fsm->sync = ec_slave_get_pdo_sync(slave, fsm->dir))) {
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   171
            if (slave->master->debug_level)
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   172
                EC_DBG("No sync manager for direction %u!\n", fsm->dir);
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
            continue;
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   174
        }
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   175
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   176
        fsm->sync_sdo_index = 0x1C10 + fsm->sync->index;
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
        if (slave->master->debug_level)
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   179
            EC_DBG("Reading Pdo assignment of sync manager %u of slave %u.\n",
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   180
                    fsm->sync->index, slave->ring_position);
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   182
        ec_pdo_list_clear_pdos(&fsm->pdos);
749
c8f1395f818a Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   183
854
f4f53be425ac Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 852
diff changeset
   184
        ec_sdo_request_address(&fsm->request, fsm->sync_sdo_index, 0);
1035
7fafc1a7451e Added response timeout to sdo_request; removed timout from fsm_coe_map.
Florian Pose <fp@igh-essen.com>
parents: 1034
diff changeset
   185
        fsm->request.response_timeout = 10000;
858
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
   186
        ecrt_sdo_request_read(&fsm->request);
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
        fsm->state = ec_fsm_coe_map_state_pdo_count;
859
233e32f428e1 Replaced ec_fsm_coe_\(upload\|download\)() with ec_fsm_coe_transfer();
Florian Pose <fp@igh-essen.com>
parents: 858
diff changeset
   188
        ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
        ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
        return;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
    }
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   192
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   193
    if (slave->master->debug_level)
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   194
        EC_DBG("Reading of Pdo assignment finished for slave %u.\n",
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   195
                slave->ring_position);
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   196
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
    fsm->state = ec_fsm_coe_map_state_end;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
}
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
/*****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
/**
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   203
 * Count assigned Pdos.
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
 */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
void ec_fsm_coe_map_state_pdo_count(
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
        ec_fsm_coe_map_t *fsm /**< finite state machine */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   208
        )
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   209
{
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
    if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   211
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   212
    if (!ec_fsm_coe_success(fsm->fsm_coe)) {
903
d13004440b6d Improved a few debugging outputs.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   213
        EC_ERR("Failed to read number of assigned Pdos from slave %u.\n",
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
                fsm->slave->ring_position);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   215
        fsm->state = ec_fsm_coe_map_state_error;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   216
        return;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   217
    }
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   218
1036
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   219
    if (fsm->request.data_size != sizeof(uint8_t)) {
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   220
        EC_ERR("Invalid data size %u returned when uploading Sdo 0x%04X:%02X "
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   221
                "from slave %u.\n", fsm->request.data_size,
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   222
                fsm->request.index, fsm->request.subindex,
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   223
                fsm->slave->ring_position);
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   224
        fsm->state = ec_fsm_coe_map_state_error;
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   225
        return;
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   226
    }
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   227
    fsm->sync_subindices = EC_READ_U8(fsm->request.data);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   228
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
    if (fsm->slave->master->debug_level)
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   230
        EC_DBG("  %u Pdos assigned.\n", fsm->sync_subindices);
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   231
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   232
    // read first Pdo
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
    fsm->sync_subindex = 1;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
    ec_fsm_coe_map_action_next_pdo(fsm);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   235
}
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   236
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   237
/*****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   238
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   239
/**
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   240
 * Read next Pdo.
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   241
 */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   242
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   243
void ec_fsm_coe_map_action_next_pdo(
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   244
        ec_fsm_coe_map_t *fsm /**< finite state machine */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   245
        )
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   246
{
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   247
    if (fsm->sync_subindex <= fsm->sync_subindices) {
854
f4f53be425ac Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 852
diff changeset
   248
        ec_sdo_request_address(&fsm->request, fsm->sync_sdo_index,
849
4b712ec8929d Removed slave pointer from ec_sdo_request_t class.
Florian Pose <fp@igh-essen.com>
parents: 847
diff changeset
   249
                fsm->sync_subindex);
1035
7fafc1a7451e Added response timeout to sdo_request; removed timout from fsm_coe_map.
Florian Pose <fp@igh-essen.com>
parents: 1034
diff changeset
   250
        fsm->request.response_timeout = 0;
858
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
   251
        ecrt_sdo_request_read(&fsm->request);
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   252
        fsm->state = ec_fsm_coe_map_state_pdo;
859
233e32f428e1 Replaced ec_fsm_coe_\(upload\|download\)() with ec_fsm_coe_transfer();
Florian Pose <fp@igh-essen.com>
parents: 858
diff changeset
   253
        ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   254
        ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   255
        return;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   256
    }
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   257
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   258
    // finished reading Pdo assignment/mapping
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   259
    
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   260
    if (ec_pdo_list_copy(&fsm->sync->pdos, &fsm->pdos)) {
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   261
        fsm->state = ec_fsm_coe_map_state_error;
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   262
        return;
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   263
    }
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   264
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   265
    fsm->sync->assign_source = EC_ASSIGN_COE;
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   266
    ec_pdo_list_clear_pdos(&fsm->pdos);
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   267
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   268
    // next direction
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   269
    ec_fsm_coe_map_action_next_dir(fsm);
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   270
}
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   271
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   272
/*****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   273
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   274
/**
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   275
 * Fetch Pdo information.
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   276
 */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   277
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   278
void ec_fsm_coe_map_state_pdo(
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   279
        ec_fsm_coe_map_t *fsm /**< finite state machine */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   280
        )
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   281
{
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   282
    if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   283
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   284
    if (!ec_fsm_coe_success(fsm->fsm_coe)) {
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   285
        EC_ERR("Failed to read assigned Pdo index from slave %u.\n",
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   286
                fsm->slave->ring_position);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   287
        fsm->state = ec_fsm_coe_map_state_error;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   288
        return;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   289
    }
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   290
1036
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   291
    if (fsm->request.data_size != sizeof(uint16_t)) {
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   292
        EC_ERR("Invalid data size %u returned when uploading Sdo 0x%04X:%02X "
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   293
                "from slave %u.\n", fsm->request.data_size,
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   294
                fsm->request.index, fsm->request.subindex,
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   295
                fsm->slave->ring_position);
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   296
        fsm->state = ec_fsm_coe_map_state_error;
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   297
        return;
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   298
    }
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   299
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   300
    if (!(fsm->pdo = (ec_pdo_t *)
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   301
                kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) {
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   302
        EC_ERR("Failed to allocate Pdo.\n");
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   303
        fsm->state = ec_fsm_coe_map_state_error;
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   304
        return;
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   305
    }
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   306
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   307
    ec_pdo_init(fsm->pdo);
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   308
    fsm->pdo->index = EC_READ_U16(fsm->request.data);
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   309
    fsm->pdo->dir = ec_sync_direction(fsm->sync);
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   310
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   311
    if (fsm->slave->master->debug_level)
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   312
        EC_DBG("  Pdo 0x%04X.\n", fsm->pdo->index);
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   313
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   314
    list_add_tail(&fsm->pdo->list, &fsm->pdos.list);
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   315
854
f4f53be425ac Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 852
diff changeset
   316
    ec_sdo_request_address(&fsm->request, fsm->pdo->index, 0);
1035
7fafc1a7451e Added response timeout to sdo_request; removed timout from fsm_coe_map.
Florian Pose <fp@igh-essen.com>
parents: 1034
diff changeset
   317
    fsm->request.response_timeout = 0;
858
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
   318
    ecrt_sdo_request_read(&fsm->request);
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   319
    fsm->state = ec_fsm_coe_map_state_pdo_entry_count;
859
233e32f428e1 Replaced ec_fsm_coe_\(upload\|download\)() with ec_fsm_coe_transfer();
Florian Pose <fp@igh-essen.com>
parents: 858
diff changeset
   320
    ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   321
    ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
}
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   323
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   324
/*****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   325
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   326
/**
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   327
 * Read number of mapped Pdo entries.
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   328
 */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   329
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   330
void ec_fsm_coe_map_state_pdo_entry_count(
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   331
        ec_fsm_coe_map_t *fsm /**< finite state machine */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   332
        )
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   333
{
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   334
    if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   335
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   336
    if (!ec_fsm_coe_success(fsm->fsm_coe)) {
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   337
        EC_ERR("Failed to read number of mapped Pdo entries from slave %u.\n",
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   338
                fsm->slave->ring_position);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   339
        fsm->state = ec_fsm_coe_map_state_error;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   340
        return;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   341
    }
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   342
1036
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   343
    if (fsm->request.data_size != sizeof(uint8_t)) {
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   344
        EC_ERR("Invalid data size %u returned when uploading Sdo 0x%04X:%02X "
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   345
                "from slave %u.\n", fsm->request.data_size,
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   346
                fsm->request.index, fsm->request.subindex,
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   347
                fsm->slave->ring_position);
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   348
        fsm->state = ec_fsm_coe_map_state_error;
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   349
        return;
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   350
    }
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   351
    fsm->pdo_subindices = EC_READ_U8(fsm->request.data);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   352
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   353
    if (fsm->slave->master->debug_level)
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   354
        EC_DBG("    %u Pdo entries mapped.\n", fsm->pdo_subindices);
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   355
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   356
    // read first Pdo entry
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   357
    fsm->pdo_subindex = 1;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   358
    ec_fsm_coe_map_action_next_pdo_entry(fsm);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   359
}
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   360
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   361
/*****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   362
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   363
/**
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   364
 * Read next Pdo entry.
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   365
 */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   366
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   367
void ec_fsm_coe_map_action_next_pdo_entry(
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   368
        ec_fsm_coe_map_t *fsm /**< finite state machine */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   369
        )
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   370
{
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   371
    if (fsm->pdo_subindex <= fsm->pdo_subindices) {
854
f4f53be425ac Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 852
diff changeset
   372
        ec_sdo_request_address(&fsm->request, fsm->pdo->index, fsm->pdo_subindex);
1035
7fafc1a7451e Added response timeout to sdo_request; removed timout from fsm_coe_map.
Florian Pose <fp@igh-essen.com>
parents: 1034
diff changeset
   373
        fsm->request.response_timeout = 0;
858
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
   374
        ecrt_sdo_request_read(&fsm->request);
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   375
        fsm->state = ec_fsm_coe_map_state_pdo_entry;
859
233e32f428e1 Replaced ec_fsm_coe_\(upload\|download\)() with ec_fsm_coe_transfer();
Florian Pose <fp@igh-essen.com>
parents: 858
diff changeset
   376
        ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   377
        ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   378
        return;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   379
    }
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   380
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   381
    // next Pdo
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   382
    fsm->sync_subindex++;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   383
    ec_fsm_coe_map_action_next_pdo(fsm);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   384
}
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   385
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   386
/*****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   387
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   388
/**
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   389
 * Read Pdo entry information.
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   390
 */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   391
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   392
void ec_fsm_coe_map_state_pdo_entry(
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   393
        ec_fsm_coe_map_t *fsm /**< finite state machine */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   394
        )
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   395
{
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   396
    if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   397
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   398
    if (!ec_fsm_coe_success(fsm->fsm_coe)) {
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   399
        EC_ERR("Failed to read mapped Pdo entry from slave %u.\n",
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   400
                fsm->slave->ring_position);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   401
        fsm->state = ec_fsm_coe_map_state_error;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   402
        return;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   403
    }
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   404
1036
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   405
    if (fsm->request.data_size != sizeof(uint32_t)) {
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   406
        EC_ERR("Invalid data size %u returned when uploading Sdo 0x%04X:%02X "
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   407
                "from slave %u.\n", fsm->request.data_size,
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   408
                fsm->request.index, fsm->request.subindex,
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   409
                fsm->slave->ring_position);
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   410
        fsm->state = ec_fsm_coe_map_state_error;
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   411
    } else {
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   412
        uint32_t pdo_entry_info;
749
c8f1395f818a Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   413
        ec_pdo_entry_t *pdo_entry;
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   414
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   415
        pdo_entry_info = EC_READ_U32(fsm->request.data);
749
c8f1395f818a Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   416
c8f1395f818a Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   417
        if (!(pdo_entry = (ec_pdo_entry_t *)
c8f1395f818a Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   418
                    kmalloc(sizeof(ec_pdo_entry_t), GFP_KERNEL))) {
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   419
            EC_ERR("Failed to allocate Pdo entry.\n");
749
c8f1395f818a Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   420
            fsm->state = ec_fsm_coe_map_state_error;
c8f1395f818a Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   421
            return;
c8f1395f818a Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   422
        }
c8f1395f818a Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   423
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 768
diff changeset
   424
        ec_pdo_entry_init(pdo_entry);
749
c8f1395f818a Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   425
        pdo_entry->index = pdo_entry_info >> 16;
c8f1395f818a Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   426
        pdo_entry->subindex = (pdo_entry_info >> 8) & 0xFF;
c8f1395f818a Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   427
        pdo_entry->bit_length = pdo_entry_info & 0xFF;
c8f1395f818a Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   428
767
3218dd94b364 Allow gaps in PDO mapping.
Florian Pose <fp@igh-essen.com>
parents: 762
diff changeset
   429
        if (!pdo_entry->index && !pdo_entry->subindex) {
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 768
diff changeset
   430
            if (ec_pdo_entry_set_name(pdo_entry, "Gap")) {
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 768
diff changeset
   431
                ec_pdo_entry_clear(pdo_entry);
767
3218dd94b364 Allow gaps in PDO mapping.
Florian Pose <fp@igh-essen.com>
parents: 762
diff changeset
   432
                kfree(pdo_entry);
3218dd94b364 Allow gaps in PDO mapping.
Florian Pose <fp@igh-essen.com>
parents: 762
diff changeset
   433
                fsm->state = ec_fsm_coe_map_state_error;
3218dd94b364 Allow gaps in PDO mapping.
Florian Pose <fp@igh-essen.com>
parents: 762
diff changeset
   434
                return;
3218dd94b364 Allow gaps in PDO mapping.
Florian Pose <fp@igh-essen.com>
parents: 762
diff changeset
   435
            }
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   436
        }
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   437
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   438
        if (fsm->slave->master->debug_level) {
926
6bb33c6ec770 Output subindices with %02X.
Florian Pose <fp@igh-essen.com>
parents: 903
diff changeset
   439
            EC_DBG("    Pdo entry 0x%04X:%02X, %u bit,  \"%s\".\n",
6bb33c6ec770 Output subindices with %02X.
Florian Pose <fp@igh-essen.com>
parents: 903
diff changeset
   440
                    pdo_entry->index, pdo_entry->subindex,
6bb33c6ec770 Output subindices with %02X.
Florian Pose <fp@igh-essen.com>
parents: 903
diff changeset
   441
                    pdo_entry->bit_length,
6bb33c6ec770 Output subindices with %02X.
Florian Pose <fp@igh-essen.com>
parents: 903
diff changeset
   442
                    pdo_entry->name ? pdo_entry->name : "???");
749
c8f1395f818a Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   443
        }
c8f1395f818a Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   444
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   445
        // next Pdo entry
749
c8f1395f818a Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   446
        list_add_tail(&pdo_entry->list, &fsm->pdo->entries);
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   447
        fsm->pdo_subindex++;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   448
        ec_fsm_coe_map_action_next_pdo_entry(fsm);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   449
    }
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   450
}
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   451
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   452
/*****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   453
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   454
/**
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   455
   State: ERROR.
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   456
*/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   457
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   458
void ec_fsm_coe_map_state_error(
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   459
        ec_fsm_coe_map_t *fsm /**< finite state machine */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   460
        )
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   461
{
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   462
}
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   463
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   464
/*****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   465
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   466
/**
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   467
   State: END.
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   468
*/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   469
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   470
void ec_fsm_coe_map_state_end(
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   471
        ec_fsm_coe_map_t *fsm /**< finite state machine */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   472
        )
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   473
{
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   474
}
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   475
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   476
/*****************************************************************************/