master/fsm_pdo_config.c
author Florian Pose <fp@igh-essen.com>
Fri, 29 Feb 2008 08:27:17 +0000
changeset 846 19248bbf9308
parent 835 23fd8b510803
child 854 f4f53be425ac
permissions -rw-r--r--
Cross blinking.
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 *  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *  This file is part of the IgH EtherCAT Master.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
 *  and/or modify it under the terms of the GNU General Public License
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
 *  as published by the Free Software Foundation; either version 2 of the
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
 *  License, or (at your option) any later version.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
 *
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
 *  The IgH EtherCAT Master is distributed in the hope that it will be
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
 *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
 *  GNU General Public License for more details.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
 *
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
 *  You should have received a copy of the GNU General Public License
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
 *  along with the IgH EtherCAT Master; if not, write to the Free Software
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
 *
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
 *  The right to use EtherCAT Technology is granted and comes free of
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
 *  charge under condition of compatibility of product made by
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
 *  Licensee. People intending to distribute/sell products based on the
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
 *  code, have to sign an agreement to guarantee that products using
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
 *  software based on IgH EtherCAT master stay compatible with the actual
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 *  EtherCAT specification (which are released themselves as an open
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
 *  standard) as the (only) precondition to have the right to use EtherCAT
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
 *  Technology, IP and trade marks.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
 *
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
 *****************************************************************************/
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
/** \file
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
 * EtherCAT Pdo configuration state machine.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
 */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
/*****************************************************************************/
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
#include "globals.h"
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
#include "master.h"
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
#include "mailbox.h"
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
#include "slave_config.h"
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
#include "fsm_pdo_config.h"
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
/*****************************************************************************/
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
void ec_fsm_pdo_config_state_start(ec_fsm_pdo_config_t *);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
void ec_fsm_pdo_config_state_zero_count(ec_fsm_pdo_config_t *);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
void ec_fsm_pdo_config_state_add_entry(ec_fsm_pdo_config_t *);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
void ec_fsm_pdo_config_state_entry_count(ec_fsm_pdo_config_t *);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
void ec_fsm_pdo_config_state_end(ec_fsm_pdo_config_t *);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
void ec_fsm_pdo_config_state_error(ec_fsm_pdo_config_t *);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
void ec_fsm_pdo_config_next_pdo(ec_fsm_pdo_config_t *);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
/*****************************************************************************/
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
/** Constructor.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
 */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
void ec_fsm_pdo_config_init(
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
        ec_fsm_pdo_config_t *fsm, /**< pdo_config state machine */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
        ec_fsm_coe_t *fsm_coe /**< CoE state machine to use */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
        )
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
{
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
    fsm->fsm_coe = fsm_coe;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
    fsm->sdodata.data = (uint8_t *) &fsm->sdo_value;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
}
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
/*****************************************************************************/
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
/** Destructor.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
 */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
void ec_fsm_pdo_config_clear(
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
        ec_fsm_pdo_config_t *fsm /**< pdo_config state machine */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
        )
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
{
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
}
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
/*****************************************************************************/
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
/** Start Pdo configuration state machine.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
 */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
void ec_fsm_pdo_config_start(
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
        ec_fsm_pdo_config_t *fsm, /**< Pdo configuration state machine */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
        ec_slave_t *slave /**< slave to configure */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
        )
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
{
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
    fsm->slave = slave;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
    fsm->state = ec_fsm_pdo_config_state_start;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
}
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
/*****************************************************************************/
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
/** Get running state.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
 *
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
 * \return false, if state machine has terminated
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
 */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
int ec_fsm_pdo_config_running(
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
        const ec_fsm_pdo_config_t *fsm /**< Pdo configuration state machine */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
        )
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
{
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
    return fsm->state != ec_fsm_pdo_config_state_end
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
        && fsm->state != ec_fsm_pdo_config_state_error;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
}
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
/*****************************************************************************/
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
/** Executes the current state.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
 *
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
 * \return false, if state machine has terminated
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
 */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
int ec_fsm_pdo_config_exec(
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
        ec_fsm_pdo_config_t *fsm /**< Pdo configuration state machine */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
        )
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
{
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
    fsm->state(fsm);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
    return ec_fsm_pdo_config_running(fsm);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
}
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
/*****************************************************************************/
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
/** Get execution result.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
 *
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
 * \return true, if the state machine terminated gracefully
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
 */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
int ec_fsm_pdo_config_success(
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
        const ec_fsm_pdo_config_t *fsm /**< Pdo configuration state machine */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
        )
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
{
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
    return fsm->state == ec_fsm_pdo_config_state_end;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
}
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
/******************************************************************************
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
 * State functions.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
 *****************************************************************************/
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
/** Start Pdo configuration.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
 */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
void ec_fsm_pdo_config_state_start(
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
        ec_fsm_pdo_config_t *fsm /**< Pdo configuration state machine */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
        )
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
{
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
    if (!fsm->slave->config) {
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
        fsm->state = ec_fsm_pdo_config_state_end;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
        return;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
    }
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
    fsm->pdo = NULL;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
    ec_fsm_pdo_config_next_pdo(fsm);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
}
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
/*****************************************************************************/
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
/** Process configuration of next Pdo.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
 */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
void ec_fsm_pdo_config_next_pdo(
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
        ec_fsm_pdo_config_t *fsm /**< Pdo configuration state machine */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
        )
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
{
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
    ec_direction_t dir;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
    const ec_pdo_mapping_t *map;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
    const ec_pdo_t *pdo, *mapped_pdo;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
    
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
    for (dir = EC_DIR_OUTPUT; dir <= EC_DIR_INPUT; dir++) {
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
        map = &fsm->slave->config->mapping[dir];
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
        list_for_each_entry(pdo, &map->pdos, list) {
801
6b1e2b0ed8bc Cleaned up Pdo mapping and configuration state machines.
Florian Pose <fp@igh-essen.com>
parents: 800
diff changeset
   170
            if (fsm->pdo) { // there was a Pdo configured in the last run
6b1e2b0ed8bc Cleaned up Pdo mapping and configuration state machines.
Florian Pose <fp@igh-essen.com>
parents: 800
diff changeset
   171
                if (pdo == fsm->pdo) // this is the last Pdo
6b1e2b0ed8bc Cleaned up Pdo mapping and configuration state machines.
Florian Pose <fp@igh-essen.com>
parents: 800
diff changeset
   172
                    fsm->pdo = NULL; // take the next one
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
            } else {
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
                if ((mapped_pdo = ec_slave_find_pdo(fsm->slave, pdo->index)))
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
                    if (ec_pdo_equal_entries(pdo, mapped_pdo))
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
                        continue; // Pdo configured correctly
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
                fsm->pdo = pdo;
801
6b1e2b0ed8bc Cleaned up Pdo mapping and configuration state machines.
Florian Pose <fp@igh-essen.com>
parents: 800
diff changeset
   179
                break;
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
            }
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
        }
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
    }
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
801
6b1e2b0ed8bc Cleaned up Pdo mapping and configuration state machines.
Florian Pose <fp@igh-essen.com>
parents: 800
diff changeset
   184
    if (!fsm->pdo) {
6b1e2b0ed8bc Cleaned up Pdo mapping and configuration state machines.
Florian Pose <fp@igh-essen.com>
parents: 800
diff changeset
   185
        if (fsm->slave->master->debug_level)
6b1e2b0ed8bc Cleaned up Pdo mapping and configuration state machines.
Florian Pose <fp@igh-essen.com>
parents: 800
diff changeset
   186
            EC_DBG("Pdo configuration finished for slave %u.\n",
6b1e2b0ed8bc Cleaned up Pdo mapping and configuration state machines.
Florian Pose <fp@igh-essen.com>
parents: 800
diff changeset
   187
                    fsm->slave->ring_position);
6b1e2b0ed8bc Cleaned up Pdo mapping and configuration state machines.
Florian Pose <fp@igh-essen.com>
parents: 800
diff changeset
   188
        fsm->state = ec_fsm_pdo_config_state_end;
6b1e2b0ed8bc Cleaned up Pdo mapping and configuration state machines.
Florian Pose <fp@igh-essen.com>
parents: 800
diff changeset
   189
        return;
6b1e2b0ed8bc Cleaned up Pdo mapping and configuration state machines.
Florian Pose <fp@igh-essen.com>
parents: 800
diff changeset
   190
    }
6b1e2b0ed8bc Cleaned up Pdo mapping and configuration state machines.
Florian Pose <fp@igh-essen.com>
parents: 800
diff changeset
   191
835
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   192
    // Pdo configuration has to be changed. Does the slave support this?
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   193
    if (fsm->slave->sii.mailbox_protocols & EC_MBOX_COE
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   194
            || (fsm->slave->sii.has_general
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   195
                && !fsm->slave->sii.coe_details.enable_pdo_configuration)) {
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   196
        EC_ERR("Slave %u does not support changing the Pdo configuration!\n",
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   197
                fsm->slave->ring_position);
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   198
        fsm->state = ec_fsm_pdo_config_state_error;
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   199
        return;
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   200
    }
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   201
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
    if (fsm->slave->master->debug_level) {
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
        EC_DBG("Changing configuration of Pdo 0x%04X of slave %u.\n",
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
                fsm->pdo->index, fsm->slave->ring_position);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
    }
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 801
diff changeset
   207
    // set mapped Pdo count to zero
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   208
    fsm->sdodata.index = fsm->pdo->index;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   209
    fsm->sdodata.subindex = 0; // number of configured entries
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
    EC_WRITE_U8(&fsm->sdo_value, 0);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   211
    fsm->sdodata.size = 1;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   212
    if (fsm->slave->master->debug_level)
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   213
        EC_DBG("Setting entry count to zero for Pdo 0x%04X.\n",
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
                fsm->pdo->index);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   215
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   216
    fsm->state = ec_fsm_pdo_config_state_zero_count;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   217
    ec_fsm_coe_download(fsm->fsm_coe, fsm->slave, &fsm->sdodata);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   218
    ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   219
}
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   221
/*****************************************************************************/
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   222
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   223
/** Process next Pdo entry.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   224
 */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   225
ec_pdo_entry_t *ec_fsm_pdo_config_next_entry(
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   226
        const ec_fsm_pdo_config_t *fsm, /**< Pdo configuration state machine */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   227
        const struct list_head *list /**< current entry list item */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   228
        )
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
{
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   230
    list = list->next; 
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   231
    if (list == &fsm->pdo->entries)
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
        return NULL; // no next entry
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
    return list_entry(list, ec_pdo_entry_t, list);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
}
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   235
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   236
/*****************************************************************************/
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   237
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   238
/** Starts to add a Pdo entry.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   239
 */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   240
void ec_fsm_pdo_config_add_entry(
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   241
        ec_fsm_pdo_config_t *fsm /**< Pdo configuration state machine. */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   242
        )
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   243
{
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   244
    uint32_t value;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   245
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   246
    fsm->sdodata.subindex = fsm->entry_count;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   247
    value = fsm->entry->index << 16
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   248
        | fsm->entry->subindex << 8 | fsm->entry->bit_length;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   249
    EC_WRITE_U32(&fsm->sdo_value, value);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   250
    fsm->sdodata.size = 4;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   251
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   252
    if (fsm->slave->master->debug_level)
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   253
        EC_DBG("Configuring Pdo entry %08X at position %u.\n",
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   254
                value, fsm->entry_count);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   255
    
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   256
    fsm->state = ec_fsm_pdo_config_state_add_entry;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   257
    ec_fsm_coe_download(fsm->fsm_coe, fsm->slave, &fsm->sdodata);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   258
    ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   259
}
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   260
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   261
/*****************************************************************************/
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   262
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   263
/** Set the number of configured entries to zero.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   264
 */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   265
void ec_fsm_pdo_config_state_zero_count(
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   266
        ec_fsm_pdo_config_t *fsm /**< Pdo configuration state machine */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   267
        )
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   268
{
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   269
    if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   270
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   271
    if (!ec_fsm_coe_success(fsm->fsm_coe)) {
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   272
        EC_ERR("Failed to clear Pdo configuration for slave %u.\n",
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   273
                fsm->slave->ring_position);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   274
        fsm->state = ec_fsm_pdo_config_state_error;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   275
        return;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   276
    }
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   277
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   278
    // find first entry
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   279
    if (!(fsm->entry =
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   280
                ec_fsm_pdo_config_next_entry(fsm, &fsm->pdo->entries))) {
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   281
        if (fsm->slave->master->debug_level)
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   282
            EC_DBG("No entries to configure for Pdo 0x%04X of slave %u.\n",
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   283
                    fsm->pdo->index, fsm->slave->ring_position);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   284
        ec_fsm_pdo_config_next_pdo(fsm);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   285
        return;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   286
    }
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   287
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   288
    // add first entry
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   289
    fsm->entry_count = 1;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   290
    ec_fsm_pdo_config_add_entry(fsm);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   291
}
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   292
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   293
/*****************************************************************************/
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   294
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   295
/** Add a Pdo entry.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   296
 */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   297
void ec_fsm_pdo_config_state_add_entry(
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   298
        ec_fsm_pdo_config_t *fsm /**< Pdo configuration state machine */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   299
        )
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   300
{
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   301
    if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   302
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   303
    if (!ec_fsm_coe_success(fsm->fsm_coe)) {
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   304
        EC_ERR("Failed to add entry 0x%04X:%u for slave %u.\n",
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   305
                fsm->entry->index, fsm->entry->subindex,
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   306
                fsm->slave->ring_position);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   307
        fsm->state = ec_fsm_pdo_config_state_error;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   308
        return;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   309
    }
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   310
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   311
    // find next entry
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   312
    if (!(fsm->entry = ec_fsm_pdo_config_next_entry(fsm, &fsm->entry->list))) {
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   313
        // No more entries to add. Write entry count.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   314
        fsm->sdodata.subindex = 0;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
        EC_WRITE_U8(&fsm->sdo_value, fsm->entry_count);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
        fsm->sdodata.size = 1;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   317
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   318
        if (fsm->slave->master->debug_level)
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   319
            EC_DBG("Setting number of Pdo entries to %u.\n",
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   320
                    fsm->entry_count);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   321
        
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
        fsm->state = ec_fsm_pdo_config_state_entry_count;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   323
        ec_fsm_coe_download(fsm->fsm_coe, fsm->slave, &fsm->sdodata);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   324
        ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   325
        return;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   326
    }
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   327
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   328
    // add next entry
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   329
    fsm->entry_count++;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   330
    ec_fsm_pdo_config_add_entry(fsm);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   331
}
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   332
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   333
/*****************************************************************************/
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   334
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   335
/** Set the number of entries.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   336
 */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   337
void ec_fsm_pdo_config_state_entry_count(
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   338
        ec_fsm_pdo_config_t *fsm /**< Pdo configuration state machine */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   339
        )
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   340
{
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   341
    if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   342
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   343
    if (!ec_fsm_coe_success(fsm->fsm_coe)) {
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   344
        EC_ERR("Failed to set number of entries for slave %u.\n",
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   345
                fsm->slave->ring_position);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   346
        fsm->state = ec_fsm_pdo_config_state_error;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   347
        return;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   348
    }
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   349
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   350
    if (fsm->slave->master->debug_level)
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   351
        EC_DBG("Successfully configured Pdo 0x%04X on slave %u.\n",
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   352
                fsm->pdo->index, fsm->slave->ring_position);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   353
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   354
    ec_fsm_pdo_config_next_pdo(fsm);
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   355
}
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   356
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   357
/******************************************************************************
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   358
 * Common state functions
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   359
 *****************************************************************************/
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   360
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   361
/** State: ERROR.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   362
 */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   363
void ec_fsm_pdo_config_state_error(
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   364
        ec_fsm_pdo_config_t *fsm /**< Pdo configuration state machine */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   365
        )
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   366
{
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   367
}
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   368
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   369
/*****************************************************************************/
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   370
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   371
/** State: END.
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   372
 */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   373
void ec_fsm_pdo_config_state_end(
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   374
        ec_fsm_pdo_config_t *fsm /**< Pdo configuration state machine */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   375
        )
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   376
{
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   377
}
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   378
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   379
/*****************************************************************************/