master/fsm_coe_map.c
author Florian Pose <fp@igh-essen.com>
Fri, 27 Jun 2008 08:58:04 +0000
changeset 1065 d1d2aa556344
parent 1058 1c5b19c1ae9d
child 1082 ff06c58e269c
permissions -rw-r--r--
United 'ethercat slaves' and 'ethercat list' with a verbose flag.
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
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
    58
void ec_fsm_coe_map_action_next_sync(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
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   137
/** Start reading Pdo assignment.
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   138
 */
751
41a5c537b76d Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 749
diff changeset
   139
void ec_fsm_coe_map_state_start(
41a5c537b76d Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 749
diff changeset
   140
        ec_fsm_coe_map_t *fsm /**< finite state machine */
41a5c537b76d Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 749
diff changeset
   141
        )
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
{
1058
1c5b19c1ae9d Begin reading of Pdo assignment at sync manager 2; removed some
Florian Pose <fp@igh-essen.com>
parents: 1055
diff changeset
   143
    // read Pdo assignment for first sync manager not reserved for mailbox
1c5b19c1ae9d Begin reading of Pdo assignment at sync manager 2; removed some
Florian Pose <fp@igh-essen.com>
parents: 1055
diff changeset
   144
    fsm->sync_index = 1; // next is 2
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   145
    ec_fsm_coe_map_action_next_sync(fsm);
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   146
}
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   147
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   148
/*****************************************************************************/
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   149
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   150
/** Read Pdo assignment of next sync manager.
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   151
 */
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   152
void ec_fsm_coe_map_action_next_sync(
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   153
        ec_fsm_coe_map_t *fsm /**< Finite state machine */
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
        )
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
{
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
    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
   157
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   158
    fsm->sync_index++;
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   159
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   160
    for (; fsm->sync_index < EC_MAX_SYNCS; fsm->sync_index++) {
1058
1c5b19c1ae9d Begin reading of Pdo assignment at sync manager 2; removed some
Florian Pose <fp@igh-essen.com>
parents: 1055
diff changeset
   161
        if (!(fsm->sync = ec_slave_get_sync(slave, fsm->sync_index)))
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
            continue;
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   163
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   164
        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
   165
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
        if (slave->master->debug_level)
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   167
            EC_DBG("Reading Pdo assignment of SM%u of slave %u.\n",
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   168
                    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
   169
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   170
        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
   171
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
   172
        ec_sdo_request_address(&fsm->request, fsm->sync_sdo_index, 0);
858
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
   173
        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
   174
        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
   175
        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
   176
        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
   177
        return;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
    }
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   180
    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
   181
        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
   182
                slave->ring_position);
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   183
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
    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
   185
}
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
/*****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
/**
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   190
 * Count assigned Pdos.
741
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
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
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
   194
        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
   195
        )
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
{
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
    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
   198
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
    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
   200
        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
   201
                fsm->slave->ring_position);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
        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
   203
        return;
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
1036
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   206
    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
   207
        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
   208
                "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
   209
                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
   210
                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
   211
        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
   212
        return;
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   213
    }
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
    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
   215
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   216
    if (fsm->slave->master->debug_level)
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   217
        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
   218
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   219
    // read first Pdo
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
    fsm->sync_subindex = 1;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   221
    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
   222
}
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   223
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   224
/*****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   225
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   226
/**
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   227
 * Read next Pdo.
741
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
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   230
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
   231
        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
   232
        )
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
{
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
    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
   235
        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
   236
                fsm->sync_subindex);
858
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
   237
        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
   238
        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
   239
        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
   240
        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
   241
        return;
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
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   244
    // 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
   245
    
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   246
    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
   247
        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
   248
        return;
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   249
    }
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   250
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   251
    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
   252
    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
   253
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   254
    // next sync manager
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   255
    ec_fsm_coe_map_action_next_sync(fsm);
741
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
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   258
/*****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   259
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   260
/**
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   261
 * Fetch Pdo information.
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   262
 */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   263
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   264
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
   265
        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
   266
        )
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   267
{
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   268
    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
   269
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   270
    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
   271
        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
   272
                fsm->slave->ring_position);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   273
        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
   274
        return;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   275
    }
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   276
1036
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   277
    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
   278
        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
   279
                "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
   280
                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
   281
                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
   282
        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
   283
        return;
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   284
    }
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   285
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   286
    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
   287
                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
   288
        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
   289
        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
   290
        return;
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   291
    }
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   292
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   293
    ec_pdo_init(fsm->pdo);
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   294
    fsm->pdo->index = EC_READ_U16(fsm->request.data);
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   295
    fsm->pdo->sync_index = fsm->sync_index;
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   296
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   297
    if (fsm->slave->master->debug_level)
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   298
        EC_DBG("Pdo 0x%04X.\n", fsm->pdo->index);
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   299
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   300
    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
   301
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
   302
    ec_sdo_request_address(&fsm->request, fsm->pdo->index, 0);
858
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
   303
    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
   304
    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
   305
    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
   306
    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
   307
}
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   308
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   309
/*****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   310
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   311
/**
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   312
 * 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
   313
 */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   314
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
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
   316
        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
   317
        )
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   318
{
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   319
    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
   320
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   321
    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
   322
        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
   323
                fsm->slave->ring_position);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   324
        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
   325
        return;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   326
    }
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   327
1036
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   328
    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
   329
        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
   330
                "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
   331
                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
   332
                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
   333
        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
   334
        return;
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   335
    }
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   336
    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
   337
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   338
    if (fsm->slave->master->debug_level)
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   339
        EC_DBG("%u Pdo entries mapped.\n", fsm->pdo_subindices);
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   340
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   341
    // 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
   342
    fsm->pdo_subindex = 1;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   343
    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
   344
}
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   345
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   346
/*****************************************************************************/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   347
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   348
/**
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   349
 * 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
   350
 */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   351
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   352
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
   353
        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
   354
        )
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   355
{
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   356
    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
   357
        ec_sdo_request_address(&fsm->request, fsm->pdo->index, fsm->pdo_subindex);
858
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
   358
        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
   359
        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
   360
        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
   361
        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
   362
        return;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   363
    }
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   364
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   365
    // next Pdo
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   366
    fsm->sync_subindex++;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   367
    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
   368
}
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
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   372
/**
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   373
 * 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
   374
 */
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   375
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   376
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
   377
        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
   378
        )
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
    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
   381
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   382
    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
   383
        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
   384
                fsm->slave->ring_position);
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   385
        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
   386
        return;
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
1036
dc2008bc8113 Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents: 1035
diff changeset
   389
    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
   390
        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
   391
                "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
   392
                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
   393
                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
   394
        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
   395
    } else {
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   396
        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
   397
        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
   398
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   399
        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
   400
c8f1395f818a Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   401
        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
   402
                    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
   403
            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
   404
            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
   405
            return;
c8f1395f818a Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   406
        }
c8f1395f818a Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   407
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 768
diff changeset
   408
        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
   409
        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
   410
        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
   411
        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
   412
767
3218dd94b364 Allow gaps in PDO mapping.
Florian Pose <fp@igh-essen.com>
parents: 762
diff changeset
   413
        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
   414
            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
   415
                ec_pdo_entry_clear(pdo_entry);
767
3218dd94b364 Allow gaps in PDO mapping.
Florian Pose <fp@igh-essen.com>
parents: 762
diff changeset
   416
                kfree(pdo_entry);
3218dd94b364 Allow gaps in PDO mapping.
Florian Pose <fp@igh-essen.com>
parents: 762
diff changeset
   417
                fsm->state = ec_fsm_coe_map_state_error;
3218dd94b364 Allow gaps in PDO mapping.
Florian Pose <fp@igh-essen.com>
parents: 762
diff changeset
   418
                return;
3218dd94b364 Allow gaps in PDO mapping.
Florian Pose <fp@igh-essen.com>
parents: 762
diff changeset
   419
            }
741
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   420
        }
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   421
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   422
        if (fsm->slave->master->debug_level) {
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1053
diff changeset
   423
            EC_DBG("Pdo entry 0x%04X:%02X, %u bit, \"%s\".\n",
926
6bb33c6ec770 Output subindices with %02X.
Florian Pose <fp@igh-essen.com>
parents: 903
diff changeset
   424
                    pdo_entry->index, pdo_entry->subindex,
6bb33c6ec770 Output subindices with %02X.
Florian Pose <fp@igh-essen.com>
parents: 903
diff changeset
   425
                    pdo_entry->bit_length,
6bb33c6ec770 Output subindices with %02X.
Florian Pose <fp@igh-essen.com>
parents: 903
diff changeset
   426
                    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
   427
        }
c8f1395f818a Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   428
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   429
        // 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
   430
        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
   431
        fsm->pdo_subindex++;
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   432
        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
   433
    }
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   434
}
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   435
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
/**
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   439
   State: ERROR.
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   440
*/
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   441
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   442
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
   443
        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
   444
        )
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   445
{
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   446
}
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   447
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   448
/*****************************************************************************/
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
   State: END.
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
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
   455
        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
   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
}
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   459
aece53f82df3 Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   460
/*****************************************************************************/