master/pdo_list.c
author Florian Pose <fp@igh-essen.com>
Wed, 19 Nov 2008 17:10:04 +0000
changeset 1316 d01d9cce8b59
parent 1313 ed15eef57d5c
child 1326 ef907b0b5125
permissions -rw-r--r--
Fixed unprocessed interrupts in e100 driver.
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 *  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *  This file is part of the IgH EtherCAT Master.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
 *  and/or modify it under the terms of the GNU General Public License
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
 *  as published by the Free Software Foundation; either version 2 of the
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
 *  License, or (at your option) any later version.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
 *
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
 *  The IgH EtherCAT Master is distributed in the hope that it will be
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
 *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
 *  GNU General Public License for more details.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
 *
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
 *  You should have received a copy of the GNU General Public License
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
 *  along with the IgH EtherCAT Master; if not, write to the Free Software
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
 *
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
 *  The right to use EtherCAT Technology is granted and comes free of
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
 *  charge under condition of compatibility of product made by
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
 *  Licensee. People intending to distribute/sell products based on the
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
 *  code, have to sign an agreement to guarantee that products using
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
 *  software based on IgH EtherCAT master stay compatible with the actual
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 *  EtherCAT specification (which are released themselves as an open
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
 *  standard) as the (only) precondition to have the right to use EtherCAT
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
 *  Technology, IP and trade marks.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
 *
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
 *****************************************************************************/
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
/**
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
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: 844
diff changeset
    36
   EtherCAT Pdo list methods.
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
*/
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
/*****************************************************************************/
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
#include <linux/module.h>
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
#include "globals.h"
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
#include "pdo.h"
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
#include "slave_config.h"
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
#include "master.h"
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    48
#include "pdo_list.h"
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    49
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    50
/*****************************************************************************/
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    51
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    52
/** Pdo list constructor.
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    53
 */
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    54
void ec_pdo_list_init(
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    55
        ec_pdo_list_t *pl /**< Pdo list. */
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    56
        )
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    57
{
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    58
    INIT_LIST_HEAD(&pl->list);
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    59
}
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    60
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    61
/*****************************************************************************/
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    62
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    63
/** Pdo list destructor.
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    64
 */
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    65
void ec_pdo_list_clear(ec_pdo_list_t *pl /**< Pdo list. */)
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    66
{
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    67
    ec_pdo_list_clear_pdos(pl);
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
}
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
/*****************************************************************************/
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
/** Clears the list of mapped Pdos.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
 */
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    74
void ec_pdo_list_clear_pdos(ec_pdo_list_t *pl /**< Pdo list. */)
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
{
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
    ec_pdo_t *pdo, *next;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    78
    list_for_each_entry_safe(pdo, next, &pl->list, list) {
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
        list_del_init(&pdo->list);
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
        ec_pdo_clear(pdo);
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
        kfree(pdo);
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
    }
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
}
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
/*****************************************************************************/
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    87
/** Calculates the total size of the mapped Pdo entries.
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
 *
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
 * \retval Data size in byte.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
 */
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    91
uint16_t ec_pdo_list_total_size(
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
    92
        const ec_pdo_list_t *pl /**< Pdo list. */
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
        )
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
{
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
    unsigned int bit_size;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
    const ec_pdo_t *pdo;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
    const ec_pdo_entry_t *pdo_entry;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
    uint16_t byte_size;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
    bit_size = 0;
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   101
    list_for_each_entry(pdo, &pl->list, list) {
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
        list_for_each_entry(pdo_entry, &pdo->entries, list) {
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
            bit_size += pdo_entry->bit_length;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
        }
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
    }
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
    if (bit_size % 8) // round up to full bytes
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
        byte_size = bit_size / 8 + 1;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
    else
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
        byte_size = bit_size / 8;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
    return byte_size;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
}
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
/*****************************************************************************/
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   117
/** Add a new Pdo to the list.
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   118
 *
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1092
diff changeset
   119
 * \return Pointer to new Pdo, otherwise an ERR_PTR() code.
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   120
 */
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   121
ec_pdo_t *ec_pdo_list_add_pdo(
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   122
        ec_pdo_list_t *pl, /**< Pdo list. */
844
8839ba8bfeb4 Fixed 2 bugs in new Pdo mapping function.
Florian Pose <fp@igh-essen.com>
parents: 842
diff changeset
   123
        uint16_t index /**< Pdo index. */
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   124
        )
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   125
{
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   126
    ec_pdo_t *pdo;
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   127
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   128
    if (!(pdo = (ec_pdo_t *) kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) {
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   129
        EC_ERR("Failed to allocate memory for Pdo.\n");
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1092
diff changeset
   130
        return ERR_PTR(-ENOMEM);
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   131
    }
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   132
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   133
    ec_pdo_init(pdo);
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   134
    pdo->index = index;
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   135
    list_add_tail(&pdo->list, &pl->list);
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   136
    return pdo;
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   137
}
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   138
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   139
/*****************************************************************************/
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   140
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   141
/** Add the copy of an existing Pdo to the list.
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
 *
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
 * \return 0 on success, else < 0
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
 */
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   145
int ec_pdo_list_add_pdo_copy(
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   146
        ec_pdo_list_t *pl, /**< Pdo list. */
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   147
        const ec_pdo_t *pdo /**< Pdo to add. */
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
        )
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
{
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
    ec_pdo_t *mapped_pdo;
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1092
diff changeset
   151
    int ret;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   153
    // Pdo already mapped?
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   154
    list_for_each_entry(mapped_pdo, &pl->list, list) {
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
        if (mapped_pdo->index != pdo->index) continue;
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   156
        EC_ERR("Pdo 0x%04X is already mapped!\n", pdo->index);
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1092
diff changeset
   157
        return -EEXIST;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
    }
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
    
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
    if (!(mapped_pdo = kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) {
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   161
        EC_ERR("Failed to allocate Pdo memory.\n");
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1092
diff changeset
   162
        return -ENOMEM;
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1092
diff changeset
   163
    }
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1092
diff changeset
   164
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1092
diff changeset
   165
    ret = ec_pdo_init_copy(mapped_pdo, pdo);
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1092
diff changeset
   166
    if (ret < 0) {
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
        kfree(mapped_pdo);
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1092
diff changeset
   168
        return ret;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
    }
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   171
    list_add_tail(&mapped_pdo->list, &pl->list);
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
    return 0;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
}
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
/*****************************************************************************/
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   177
/** Makes a deep copy of another Pdo list.
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
 *
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
 * \return 0 on success, else < 0
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
 */
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   181
int ec_pdo_list_copy(
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   182
        ec_pdo_list_t *pl, /**< Pdo list. */
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   183
        const ec_pdo_list_t *other /**< Pdo list to copy from. */
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
        )
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
{
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
    ec_pdo_t *other_pdo;
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1092
diff changeset
   187
    int ret;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   189
    ec_pdo_list_clear_pdos(pl);
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   191
    // Pdo already mapped?
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   192
    list_for_each_entry(other_pdo, &other->list, list) {
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1092
diff changeset
   193
        ret = ec_pdo_list_add_pdo_copy(pl, other_pdo);
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1092
diff changeset
   194
        if (ret)
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1092
diff changeset
   195
            return ret;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
    }
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
    
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
    return 0;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
}
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
/*****************************************************************************/
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   203
/** Compares two Pdo lists.
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   204
 *
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   205
 * Only the list is compared, not the Pdo entries (i. e. the Pdo
1049
91a0d7226e0b Minor change.
Florian Pose <fp@igh-essen.com>
parents: 932
diff changeset
   206
 * mapping).
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
 *
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   208
 * \retval 1 The given Pdo lists are equal.
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   209
 * \retval 0 The given Pdo lists differ.
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   210
 */
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   211
int ec_pdo_list_equal(
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   212
        const ec_pdo_list_t *pl1, /**< First list. */
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   213
        const ec_pdo_list_t *pl2 /**< Second list. */
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
        )
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   215
{
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   216
    const struct list_head *h1, *h2, *l1, *l2;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   217
    const ec_pdo_t *p1, *p2;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   218
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   219
    h1 = l1 = &pl1->list;
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   220
    h2 = l2 = &pl2->list;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   221
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   222
    while (1) {
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   223
        l1 = l1->next;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   224
        l2 = l2->next;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   225
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   226
        if ((l1 == h1) ^ (l2 == h2)) // unequal lengths
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   227
            return 0;
826
70aeae0de217 Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   228
        if (l1 == h1) // both finished
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
            break;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   230
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   231
        p1 = list_entry(l1, ec_pdo_t, list);
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
        p2 = list_entry(l2, ec_pdo_t, list);
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
        if (p1->index != p2->index)
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   235
            return 0;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   236
    }
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   237
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   238
    return 1;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   239
}
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   240
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   241
/*****************************************************************************/
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 793
diff changeset
   242
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   243
/** Finds a Pdo with the given index.
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   244
 */
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   245
ec_pdo_t *ec_pdo_list_find_pdo(
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   246
        const ec_pdo_list_t *pl, /**< Pdo list. */
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 793
diff changeset
   247
        uint16_t index /**< Pdo index. */
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 793
diff changeset
   248
        )
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 793
diff changeset
   249
{
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   250
    ec_pdo_t *pdo;
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 793
diff changeset
   251
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   252
    list_for_each_entry(pdo, &pl->list, list) {
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 793
diff changeset
   253
        if (pdo->index != index)
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 793
diff changeset
   254
            continue;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 793
diff changeset
   255
        return pdo;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 793
diff changeset
   256
    }
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 793
diff changeset
   257
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 793
diff changeset
   258
    return NULL;
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 793
diff changeset
   259
}
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 793
diff changeset
   260
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 793
diff changeset
   261
/*****************************************************************************/
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   262
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   263
/** Finds a Pdo with the given index and returns a const pointer.
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   264
 */
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   265
const ec_pdo_t *ec_pdo_list_find_pdo_const(
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   266
        const ec_pdo_list_t *pl, /**< Pdo list. */
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   267
        uint16_t index /**< Pdo index. */
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   268
        )
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   269
{
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   270
    const ec_pdo_t *pdo;
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   271
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   272
    list_for_each_entry(pdo, &pl->list, list) {
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   273
        if (pdo->index != index)
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   274
            continue;
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   275
        return pdo;
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   276
    }
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   277
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   278
    return NULL;
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   279
}
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   280
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 839
diff changeset
   281
/*****************************************************************************/
931
482bbaf3e76b Added ec_pdo_list_count().
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   282
932
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   283
/** Finds a Pdo via its position in the list.
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   284
 *
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   285
 * Const version.
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   286
 */
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   287
const ec_pdo_t *ec_pdo_list_find_pdo_by_pos_const(
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   288
        const ec_pdo_list_t *pl, /**< Pdo list. */
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   289
        unsigned int pos /**< Position in the list. */
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   290
        )
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   291
{
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   292
    const ec_pdo_t *pdo;
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   293
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   294
    list_for_each_entry(pdo, &pl->list, list) {
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   295
        if (pos--)
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   296
            continue;
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   297
        return pdo;
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   298
    }
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   299
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   300
    return NULL;
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   301
}
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   302
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   303
/*****************************************************************************/
dbcc06156a60 Added ec_pdo_list_find_by_pos_const().
Florian Pose <fp@igh-essen.com>
parents: 931
diff changeset
   304
1092
69393cf60399 Improved source code doc.
Florian Pose <fp@igh-essen.com>
parents: 1055
diff changeset
   305
/** Get the number of Pdos in the list.
69393cf60399 Improved source code doc.
Florian Pose <fp@igh-essen.com>
parents: 1055
diff changeset
   306
 *
69393cf60399 Improved source code doc.
Florian Pose <fp@igh-essen.com>
parents: 1055
diff changeset
   307
 * \return Number of Pdos.
931
482bbaf3e76b Added ec_pdo_list_count().
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   308
 */
482bbaf3e76b Added ec_pdo_list_count().
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   309
unsigned int ec_pdo_list_count(
482bbaf3e76b Added ec_pdo_list_count().
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   310
        const ec_pdo_list_t *pl /**< Pdo list. */
482bbaf3e76b Added ec_pdo_list_count().
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   311
        )
482bbaf3e76b Added ec_pdo_list_count().
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   312
{
482bbaf3e76b Added ec_pdo_list_count().
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   313
    const ec_pdo_t *pdo;
482bbaf3e76b Added ec_pdo_list_count().
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   314
    unsigned int num = 0;
482bbaf3e76b Added ec_pdo_list_count().
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   315
482bbaf3e76b Added ec_pdo_list_count().
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   316
    list_for_each_entry(pdo, &pl->list, list) {
482bbaf3e76b Added ec_pdo_list_count().
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   317
        num++;
482bbaf3e76b Added ec_pdo_list_count().
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   318
    }
482bbaf3e76b Added ec_pdo_list_count().
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   319
482bbaf3e76b Added ec_pdo_list_count().
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   320
    return num;
482bbaf3e76b Added ec_pdo_list_count().
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   321
}
482bbaf3e76b Added ec_pdo_list_count().
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   322
482bbaf3e76b Added ec_pdo_list_count().
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   323
/*****************************************************************************/
1051
40a4f31ec3b8 Added ec_pdo_list_print().
Florian Pose <fp@igh-essen.com>
parents: 1049
diff changeset
   324
40a4f31ec3b8 Added ec_pdo_list_print().
Florian Pose <fp@igh-essen.com>
parents: 1049
diff changeset
   325
/** Outputs the Pdos in the list.
40a4f31ec3b8 Added ec_pdo_list_print().
Florian Pose <fp@igh-essen.com>
parents: 1049
diff changeset
   326
 */
40a4f31ec3b8 Added ec_pdo_list_print().
Florian Pose <fp@igh-essen.com>
parents: 1049
diff changeset
   327
void ec_pdo_list_print(
40a4f31ec3b8 Added ec_pdo_list_print().
Florian Pose <fp@igh-essen.com>
parents: 1049
diff changeset
   328
        const ec_pdo_list_t *pl /**< Pdo list. */
40a4f31ec3b8 Added ec_pdo_list_print().
Florian Pose <fp@igh-essen.com>
parents: 1049
diff changeset
   329
        )
40a4f31ec3b8 Added ec_pdo_list_print().
Florian Pose <fp@igh-essen.com>
parents: 1049
diff changeset
   330
{
40a4f31ec3b8 Added ec_pdo_list_print().
Florian Pose <fp@igh-essen.com>
parents: 1049
diff changeset
   331
    const ec_pdo_t *pdo;
40a4f31ec3b8 Added ec_pdo_list_print().
Florian Pose <fp@igh-essen.com>
parents: 1049
diff changeset
   332
40a4f31ec3b8 Added ec_pdo_list_print().
Florian Pose <fp@igh-essen.com>
parents: 1049
diff changeset
   333
    list_for_each_entry(pdo, &pl->list, list) {
40a4f31ec3b8 Added ec_pdo_list_print().
Florian Pose <fp@igh-essen.com>
parents: 1049
diff changeset
   334
        printk("0x%04X", pdo->index);
40a4f31ec3b8 Added ec_pdo_list_print().
Florian Pose <fp@igh-essen.com>
parents: 1049
diff changeset
   335
        if (pdo->list.next != &pl->list)
40a4f31ec3b8 Added ec_pdo_list_print().
Florian Pose <fp@igh-essen.com>
parents: 1049
diff changeset
   336
            printk(" ");
40a4f31ec3b8 Added ec_pdo_list_print().
Florian Pose <fp@igh-essen.com>
parents: 1049
diff changeset
   337
    }
40a4f31ec3b8 Added ec_pdo_list_print().
Florian Pose <fp@igh-essen.com>
parents: 1049
diff changeset
   338
}
40a4f31ec3b8 Added ec_pdo_list_print().
Florian Pose <fp@igh-essen.com>
parents: 1049
diff changeset
   339
40a4f31ec3b8 Added ec_pdo_list_print().
Florian Pose <fp@igh-essen.com>
parents: 1049
diff changeset
   340
/*****************************************************************************/