master/slave_config.c
author Knud Baastrup <kba@deif.com>
Tue, 14 Apr 2015 10:12:55 -0400
changeset 2625 e25af8bd3957
parent 2620 0e4d098db815
child 2635 42b62867574d
permissions -rwxr-xr-x
Eoe mac address now derived from unique mac.
The EoE MAC address is now derived from the NIC part of the first global
unique MAC address of the linked list of available network interfaces or
otherwise the MAC address used by the EtherCAT master. The EoE MAC address
will get the format 02:NIC:NIC:NIC:RP:RP where NIC comes from the unique MAC
address (if available) and RP is the ring position of the EoE slave.
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
 *
2411
01370d59233d Malformed hg keywords.
Florian Pose <fp@igh-essen.com>
parents: 2402
diff changeset
     3
 *  $Id$
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
     5
 *  Copyright (C) 2006-2012  Florian Pose, Ingenieurgemeinschaft IgH
792
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
 *
1326
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it and/or
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    10
 *  modify it under the terms of the GNU General Public License version 2, as
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    11
 *  published by the Free Software Foundation.
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    12
 *
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    13
 *  The IgH EtherCAT Master is distributed in the hope that it will be useful,
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    16
 *  Public License for more details.
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    17
 *
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    18
 *  You should have received a copy of the GNU General Public License along
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    19
 *  with the IgH EtherCAT Master; if not, write to the Free Software
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
 *  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
    21
 *
1363
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1351
diff changeset
    22
 *  ---
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1351
diff changeset
    23
 *
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1351
diff changeset
    24
 *  The license mentioned above concerns the source code only. Using the
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1351
diff changeset
    25
 *  EtherCAT technology and brand is only permitted in compliance with the
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1351
diff changeset
    26
 *  industrial property and similar rights of Beckhoff Automation GmbH.
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
 *
1873
219be3742274 Added missing queue_external_datagram(); removed tabs.
Florian Pose <fp@igh-essen.com>
parents: 1844
diff changeset
    28
 *  vim: expandtab
219be3742274 Added missing queue_external_datagram(); removed tabs.
Florian Pose <fp@igh-essen.com>
parents: 1844
diff changeset
    29
 *
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
 *****************************************************************************/
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
   \file
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
   EtherCAT slave configuration methods.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
*/
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
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
2402
1a450b095f3b Added missing linux/modules.h include.
Florian Pose <fp@igh-essen.com>
parents: 2151
diff changeset
    39
#include <linux/module.h>
995
54149a703c47 Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents: 990
diff changeset
    40
#include <linux/slab.h>
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
#include "globals.h"
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
#include "master.h"
1209
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
    44
#include "voe_handler.h"
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
#include "slave_config.h"
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
/*****************************************************************************/
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
/** Slave configuration constructor.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
 *
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
 * See ecrt_master_slave_config() for the usage of the \a alias and \a
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
 * position parameters.
995
54149a703c47 Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents: 990
diff changeset
    54
 */
54149a703c47 Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents: 990
diff changeset
    55
void ec_slave_config_init(
54149a703c47 Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents: 990
diff changeset
    56
        ec_slave_config_t *sc, /**< Slave configuration. */
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
        ec_master_t *master, /**< EtherCAT master. */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
        uint16_t alias, /**< Slave alias. */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
        uint16_t position, /**< Slave position. */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
        uint32_t vendor_id, /**< Expected vendor ID. */
1010
6672b86e7b10 Reverted revision number checking from r1228.
Florian Pose <fp@igh-essen.com>
parents: 1009
diff changeset
    61
        uint32_t product_code /**< Expected product code. */
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
        )
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
{
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
    64
    unsigned int i;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
    sc->master = master;
1392
8fcc1d0987c1 DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    67
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
    sc->alias = alias;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
    sc->position = position;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
    sc->vendor_id = vendor_id;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
    sc->product_code = product_code;
1509
a864688e7de5 Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents: 1507
diff changeset
    72
    sc->watchdog_divider = 0; // use default
2609
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
    73
    sc->allow_overlapping_pdos = 0; // default not allowed
1509
a864688e7de5 Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents: 1507
diff changeset
    74
    sc->watchdog_intervals = 0; // use default
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
    75
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
    sc->slave = NULL;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
1082
ff06c58e269c Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
    78
    for (i = 0; i < EC_MAX_SYNC_MANAGERS; i++)
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
    79
        ec_sync_config_init(&sc->sync_configs[i]);
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
1392
8fcc1d0987c1 DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    81
    sc->used_fmmus = 0;
1507
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
    82
    sc->dc_assign_activate = 0x0000;
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
    83
    sc->dc_sync[0].cycle_time = 0U;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
    84
    sc->dc_sync[1].cycle_time = 0;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
    85
    sc->dc_sync[0].shift_time = 0U;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
    86
    sc->dc_sync[1].shift_time = 0;
1392
8fcc1d0987c1 DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    87
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
    INIT_LIST_HEAD(&sc->sdo_configs);
858
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
    89
    INIT_LIST_HEAD(&sc->sdo_requests);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
    90
    INIT_LIST_HEAD(&sc->reg_requests);
1209
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
    91
    INIT_LIST_HEAD(&sc->voe_handlers);
1844
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
    92
    INIT_LIST_HEAD(&sc->soe_configs);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
    93
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
    94
    ec_coe_emerg_ring_init(&sc->emerg_ring, sc);
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
}
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
/*****************************************************************************/
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
/** Slave configuration destructor.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
 *
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
 * Clears and frees a slave configuration object.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
 */
995
54149a703c47 Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents: 990
diff changeset
   103
void ec_slave_config_clear(
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
        ec_slave_config_t *sc /**< Slave configuration. */
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
{
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   107
    unsigned int i;
854
f4f53be425ac Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   108
    ec_sdo_request_t *req, *next_req;
1209
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
   109
    ec_voe_handler_t *voe, *next_voe;
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   110
    ec_reg_request_t *reg, *next_reg;
1844
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
   111
    ec_soe_request_t *soe, *next_soe;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
995
54149a703c47 Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents: 990
diff changeset
   113
    ec_slave_config_detach(sc);
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   115
    // Free sync managers
1082
ff06c58e269c Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   116
    for (i = 0; i < EC_MAX_SYNC_MANAGERS; i++)
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   117
        ec_sync_config_clear(&sc->sync_configs[i]);
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
   119
    // free all SDO configurations
854
f4f53be425ac Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   120
    list_for_each_entry_safe(req, next_req, &sc->sdo_configs, list) {
f4f53be425ac Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   121
        list_del(&req->list);
f4f53be425ac Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   122
        ec_sdo_request_clear(req);
f4f53be425ac Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   123
        kfree(req);
f4f53be425ac Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 844
diff changeset
   124
    }
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
   126
    // free all SDO requests
858
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
   127
    list_for_each_entry_safe(req, next_req, &sc->sdo_requests, list) {
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
   128
        list_del(&req->list);
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
   129
        ec_sdo_request_clear(req);
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
   130
        kfree(req);
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
   131
    }
1209
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
   132
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   133
    // free all register requests
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   134
    list_for_each_entry_safe(reg, next_reg, &sc->reg_requests, list) {
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   135
        list_del(&reg->list);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   136
        ec_reg_request_clear(reg);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   137
        kfree(reg);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   138
    }
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   139
1209
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
   140
    // free all VoE handlers
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
   141
    list_for_each_entry_safe(voe, next_voe, &sc->voe_handlers, list) {
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
   142
        list_del(&voe->list);
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
   143
        ec_voe_handler_clear(voe);
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
   144
        kfree(voe);
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
   145
    }
1844
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
   146
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
   147
    // free all SoE configurations
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
   148
    list_for_each_entry_safe(soe, next_soe, &sc->soe_configs, list) {
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
   149
        list_del(&soe->list);
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
   150
        ec_soe_request_clear(soe);
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
   151
        kfree(soe);
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
   152
    }
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   153
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   154
    ec_coe_emerg_ring_clear(&sc->emerg_ring);
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
}
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
/*****************************************************************************/
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
/** Prepares an FMMU configuration.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
 *
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
 * Configuration data for the FMMU is saved in the slave config structure and
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
 * is written to the slave during the configuration. The FMMU configuration
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
 * is done in a way, that the complete data range of the corresponding sync
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
 * manager is covered. Seperate FMMUs are configured for each domain. If the
916
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 893
diff changeset
   165
 * FMMU configuration is already prepared, the function does nothing and
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 893
diff changeset
   166
 * returns with success.
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 893
diff changeset
   167
 *
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 893
diff changeset
   168
 * \retval >=0 Success, logical offset byte address.
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   169
 * \retval  <0 Error code.
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
 */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
int ec_slave_config_prepare_fmmu(
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
        ec_slave_config_t *sc, /**< Slave configuration. */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
        ec_domain_t *domain, /**< Domain. */
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   174
        uint8_t sync_index, /**< Sync manager index. */
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
   175
        ec_direction_t dir /**< PDO direction. */
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
        )
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
{
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
    unsigned int i;
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   179
    ec_fmmu_config_t *fmmu;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
    // FMMU configuration already prepared?
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
    for (i = 0; i < sc->used_fmmus; i++) {
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
        fmmu = &sc->fmmu_configs[i];
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   184
        if (fmmu->domain == domain && fmmu->sync_index == sync_index)
2610
f0fdcce9874b Refactor fmmu->logical_start_address to fmmu->logical_domain_offset
Dave Page <dave.page@gleeble.com>
parents: 2609
diff changeset
   185
            return fmmu->logical_domain_offset;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
    }
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
    if (sc->used_fmmus == EC_MAX_FMMUS) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   189
        EC_CONFIG_ERR(sc, "FMMU limit reached!\n");
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   190
        return -EOVERFLOW;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
    }
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   192
2609
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   193
    fmmu = &sc->fmmu_configs[sc->used_fmmus];
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   194
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   195
    down(&sc->master->master_sem);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   196
    ec_fmmu_config_init(fmmu, sc, domain, sync_index, dir);
2609
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   197
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   198
#if 0 //TODO overlapping PDOs
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   199
    // Overlapping PDO Support from 4751747d4e6d
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   200
    // FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   201
    // parent code does not call ec_fmmu_config_domain
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   202
    // FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   203
    fmmu_logical_start_address = domain->tx_size;
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   204
    tx_size = fmmu->data_size;
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   205
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   206
    // FIXME is it enough to take only the *previous* FMMU into account?
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   207
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   208
    // FIXME Need to qualify allow_overlapping_pdos with slave->sii.general_flags.enable_not_lrw
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   209
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   210
    if (sc->allow_overlapping_pdos && sc->used_fmmus > 0) {
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   211
        prev_fmmu = &sc->fmmu_configs[sc->used_fmmus - 1];
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   212
        if (fmmu->dir != prev_fmmu->dir && prev_fmmu->tx_size != 0) {
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   213
            // prev fmmu has opposite direction
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   214
            // and is not already paired with prev-prev fmmu
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   215
            old_prev_tx_size = prev_fmmu->tx_size;
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   216
            prev_fmmu->tx_size = max(fmmu->data_size, prev_fmmu->data_size);
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   217
            domain->tx_size += prev_fmmu->tx_size - old_prev_tx_size;
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   218
            tx_size = 0;
2610
f0fdcce9874b Refactor fmmu->logical_start_address to fmmu->logical_domain_offset
Dave Page <dave.page@gleeble.com>
parents: 2609
diff changeset
   219
            fmmu_logical_start_address = prev_fmmu->logical_domain_offset;
2609
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   220
        }
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   221
    }
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   222
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   223
    ec_fmmu_config_domain(fmmu, domain, fmmu_logical_start_address, tx_size);
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   224
    // Overlapping PDO Support from 4751747d4e6d
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   225
#endif
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   226
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   227
    sc->used_fmmus++;
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   228
    up(&sc->master->master_sem);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   229
2610
f0fdcce9874b Refactor fmmu->logical_start_address to fmmu->logical_domain_offset
Dave Page <dave.page@gleeble.com>
parents: 2609
diff changeset
   230
    return fmmu->logical_domain_offset;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   231
}
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
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
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   235
/** Attaches the configuration to the addressed slave object.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   236
 *
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   237
 * \retval  0 Success.
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   238
 * \retval <0 Error code.
792
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
int ec_slave_config_attach(
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   241
        ec_slave_config_t *sc /**< Slave configuration. */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   242
        )
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   243
{
1507
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   244
    ec_slave_t *slave;
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   245
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   246
    if (sc->slave)
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   247
        return 0; // already attached
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   248
927
ffb7d1876ce0 Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents: 926
diff changeset
   249
    if (!(slave = ec_master_find_slave(
ffb7d1876ce0 Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents: 926
diff changeset
   250
                    sc->master, sc->alias, sc->position))) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   251
        EC_CONFIG_DBG(sc, 1, "Failed to find slave for configuration.\n");
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   252
        return -ENOENT;
927
ffb7d1876ce0 Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents: 926
diff changeset
   253
    }
ffb7d1876ce0 Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents: 926
diff changeset
   254
1507
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   255
    if (slave->config) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   256
        EC_CONFIG_DBG(sc, 1, "Failed to attach configuration. Slave %u"
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   257
                " already has a configuration!\n", slave->ring_position);
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   258
        return -EEXIST;
1025
ae175095f09a Output attachment failure messages only when debugging.
Florian Pose <fp@igh-essen.com>
parents: 1022
diff changeset
   259
    }
1145
133cf4631fcc Force reconfiguration after attachment.
Florian Pose <fp@igh-essen.com>
parents: 1115
diff changeset
   260
2151
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   261
    if (
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   262
#ifdef EC_IDENT_WILDCARDS
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   263
            sc->vendor_id != 0xffffffff &&
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   264
#endif
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   265
            slave->sii.vendor_id != sc->vendor_id
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   266
       ) {
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   267
        EC_CONFIG_DBG(sc, 1, "Slave %u has no matching vendor ID (0x%08X)"
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   268
                " for configuration (0x%08X).\n",
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   269
                slave->ring_position, slave->sii.vendor_id, sc->vendor_id);
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   270
        return -EINVAL;
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   271
    }
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   272
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   273
    if (
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   274
#ifdef EC_IDENT_WILDCARDS
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   275
            sc->product_code != 0xffffffff &&
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   276
#endif
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   277
            slave->sii.product_code != sc->product_code
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   278
       ) {
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   279
        EC_CONFIG_DBG(sc, 1, "Slave %u has no matching product code (0x%08X)"
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   280
                " for configuration (0x%08X).\n",
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   281
                slave->ring_position, slave->sii.product_code,
4751747d4e6d Added --enable-wildcards to use 0xffffffff as wildcard for vendor ID and
Florian Pose <fp@igh-essen.com>
parents: 2103
diff changeset
   282
                sc->product_code);
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   283
        return -EINVAL;
1507
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   284
    }
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   285
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   286
    // attach slave
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   287
    slave->config = sc;
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   288
    sc->slave = slave;
1145
133cf4631fcc Force reconfiguration after attachment.
Florian Pose <fp@igh-essen.com>
parents: 1115
diff changeset
   289
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   290
    EC_CONFIG_DBG(sc, 1, "Attached slave %u.\n", slave->ring_position);
1507
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   291
    return 0;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   292
}
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   293
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   294
/*****************************************************************************/
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   295
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   296
/** Detaches the configuration from a slave object.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   297
 */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   298
void ec_slave_config_detach(
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   299
        ec_slave_config_t *sc /**< Slave configuration. */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   300
        )
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   301
{
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   302
    if (sc->slave) {
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   303
        ec_reg_request_t *reg;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   304
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   305
        sc->slave->config = NULL;
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   306
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   307
        // invalidate processing register request
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   308
        list_for_each_entry(reg, &sc->reg_requests, list) {
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   309
            if (sc->slave->fsm.reg_request == reg) {
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   310
                sc->slave->fsm.reg_request = NULL;
2619
f2bc4000e47a When detaching a slave from a slave_config, fail any pending register requests instead of leaving them BUSY forever.
Gavin Lambert <gavinl@compacsort.com>
parents: 2610
diff changeset
   311
                EC_SLAVE_WARN(sc->slave, "Aborting register request,"
f2bc4000e47a When detaching a slave from a slave_config, fail any pending register requests instead of leaving them BUSY forever.
Gavin Lambert <gavinl@compacsort.com>
parents: 2610
diff changeset
   312
                        " slave is detaching.\n");
f2bc4000e47a When detaching a slave from a slave_config, fail any pending register requests instead of leaving them BUSY forever.
Gavin Lambert <gavinl@compacsort.com>
parents: 2610
diff changeset
   313
                reg->state = EC_INT_REQUEST_FAILURE;
f2bc4000e47a When detaching a slave from a slave_config, fail any pending register requests instead of leaving them BUSY forever.
Gavin Lambert <gavinl@compacsort.com>
parents: 2610
diff changeset
   314
                wake_up_all(&sc->slave->master->request_queue);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   315
                break;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   316
            }
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   317
        }
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   318
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   319
        sc->slave = NULL;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   320
    }
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   321
}
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   323
/*****************************************************************************/
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   324
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
   325
/** Loads the default PDO assignment from the slave object.
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   326
 */
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   327
void ec_slave_config_load_default_sync_config(ec_slave_config_t *sc)
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   328
{
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   329
    uint8_t sync_index;
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   330
    ec_sync_config_t *sync_config;
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   331
    const ec_sync_t *sync;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   332
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   333
    if (!sc->slave)
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   334
        return;
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   335
1082
ff06c58e269c Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   336
    for (sync_index = 0; sync_index < EC_MAX_SYNC_MANAGERS; sync_index++) {
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   337
        sync_config = &sc->sync_configs[sync_index];
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   338
        if ((sync = ec_slave_get_sync(sc->slave, sync_index))) {
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   339
            sync_config->dir = ec_sync_default_direction(sync);
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   340
            if (sync_config->dir == EC_DIR_INVALID)
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   341
                EC_SLAVE_WARN(sc->slave,
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   342
                        "SM%u has an invalid direction field!\n", sync_index);
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   343
            ec_pdo_list_copy(&sync_config->pdos, &sync->pdos);
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   344
        }
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   345
    }
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   346
}
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   347
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   348
/*****************************************************************************/
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   349
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
   350
/** Loads the default mapping for a PDO from the slave object.
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   351
 */
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   352
void ec_slave_config_load_default_mapping(
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   353
        const ec_slave_config_t *sc,
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   354
        ec_pdo_t *pdo
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   355
        )
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   356
{
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   357
    unsigned int i;
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   358
    const ec_sync_t *sync;
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   359
    const ec_pdo_t *default_pdo;
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   360
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   361
    if (!sc->slave)
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   362
        return;
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   363
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   364
    EC_CONFIG_DBG(sc, 1, "Loading default mapping for PDO 0x%04X.\n",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   365
            pdo->index);
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   366
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
   367
    // find PDO in any sync manager (it could be reassigned later)
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   368
    for (i = 0; i < sc->slave->sii.sync_count; i++) {
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   369
        sync = &sc->slave->sii.syncs[i];
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   370
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   371
        list_for_each_entry(default_pdo, &sync->pdos.list, list) {
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   372
            if (default_pdo->index != pdo->index)
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   373
                continue;
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   374
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   375
            if (default_pdo->name) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   376
                EC_CONFIG_DBG(sc, 1, "Found PDO name \"%s\".\n",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   377
                        default_pdo->name);
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
   378
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
   379
                // take PDO name from assigned one
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   380
                ec_pdo_set_name(pdo, default_pdo->name);
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   381
            }
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   382
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
   383
            // copy entries (= default PDO mapping)
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   384
            if (ec_pdo_copy_entries(pdo, default_pdo))
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   385
                return;
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   386
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   387
            if (sc->master->debug_level) {
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   388
                const ec_pdo_entry_t *entry;
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   389
                list_for_each_entry(entry, &pdo->entries, list) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   390
                    EC_CONFIG_DBG(sc, 1, "Entry 0x%04X:%02X.\n",
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   391
                            entry->index, entry->subindex);
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   392
                }
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   393
            }
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   394
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   395
            return;
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   396
        }
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   397
    }
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   398
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   399
    EC_CONFIG_DBG(sc, 1, "No default mapping found.\n");
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   400
}
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   401
990
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   402
/*****************************************************************************/
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   403
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
   404
/** Get the number of SDO configurations.
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
   405
 *
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
   406
 * \return Number of SDO configurations.
1092
69393cf60399 Improved source code doc.
Florian Pose <fp@igh-essen.com>
parents: 1082
diff changeset
   407
 */
990
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   408
unsigned int ec_slave_config_sdo_count(
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   409
        const ec_slave_config_t *sc /**< Slave configuration. */
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   410
        )
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   411
{
1507
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   412
    const ec_sdo_request_t *req;
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   413
    unsigned int count = 0;
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   414
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   415
    list_for_each_entry(req, &sc->sdo_configs, list) {
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   416
        count++;
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   417
    }
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   418
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   419
    return count;
990
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   420
}
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   421
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   422
/*****************************************************************************/
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   423
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
   424
/** Finds an SDO configuration via its position in the list.
990
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   425
 *
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   426
 * Const version.
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   427
 *
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   428
 * \return Search result, or NULL.
990
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   429
 */
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   430
const ec_sdo_request_t *ec_slave_config_get_sdo_by_pos_const(
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   431
        const ec_slave_config_t *sc, /**< Slave configuration. */
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   432
        unsigned int pos /**< Position in the list. */
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   433
        )
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   434
{
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   435
    const ec_sdo_request_t *req;
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   436
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   437
    list_for_each_entry(req, &sc->sdo_configs, list) {
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   438
        if (pos--)
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   439
            continue;
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   440
        return req;
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   441
    }
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   442
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   443
    return NULL;
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   444
}
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 941
diff changeset
   445
1263
f44720defbc5 Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents: 1215
diff changeset
   446
/*****************************************************************************/
f44720defbc5 Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents: 1215
diff changeset
   447
1966
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   448
/** Get the number of IDN configurations.
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   449
 *
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   450
 * \return Number of SDO configurations.
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   451
 */
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   452
unsigned int ec_slave_config_idn_count(
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   453
        const ec_slave_config_t *sc /**< Slave configuration. */
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   454
        )
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   455
{
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   456
    const ec_soe_request_t *req;
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   457
    unsigned int count = 0;
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   458
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   459
    list_for_each_entry(req, &sc->soe_configs, list) {
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   460
        count++;
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   461
    }
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   462
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   463
    return count;
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   464
}
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   465
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   466
/*****************************************************************************/
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   467
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   468
/** Finds an IDN configuration via its position in the list.
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   469
 *
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   470
 * Const version.
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   471
 *
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   472
 * \return Search result, or NULL.
1966
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   473
 */
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   474
const ec_soe_request_t *ec_slave_config_get_idn_by_pos_const(
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   475
        const ec_slave_config_t *sc, /**< Slave configuration. */
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   476
        unsigned int pos /**< Position in the list. */
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   477
        )
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   478
{
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   479
    const ec_soe_request_t *req;
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   480
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   481
    list_for_each_entry(req, &sc->soe_configs, list) {
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   482
        if (pos--)
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   483
            continue;
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   484
        return req;
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   485
    }
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   486
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   487
    return NULL;
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   488
}
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   489
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   490
/*****************************************************************************/
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
   491
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   492
/** Finds a CoE handler via its position in the list.
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   493
 *
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   494
 * \return Search result, or NULL.
1263
f44720defbc5 Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents: 1215
diff changeset
   495
 */
1351
cf8f08631c8e Added ec_slave_config_find_sdo_request().
Florian Pose <fp@igh-essen.com>
parents: 1332
diff changeset
   496
ec_sdo_request_t *ec_slave_config_find_sdo_request(
cf8f08631c8e Added ec_slave_config_find_sdo_request().
Florian Pose <fp@igh-essen.com>
parents: 1332
diff changeset
   497
        ec_slave_config_t *sc, /**< Slave configuration. */
cf8f08631c8e Added ec_slave_config_find_sdo_request().
Florian Pose <fp@igh-essen.com>
parents: 1332
diff changeset
   498
        unsigned int pos /**< Position in the list. */
cf8f08631c8e Added ec_slave_config_find_sdo_request().
Florian Pose <fp@igh-essen.com>
parents: 1332
diff changeset
   499
        )
cf8f08631c8e Added ec_slave_config_find_sdo_request().
Florian Pose <fp@igh-essen.com>
parents: 1332
diff changeset
   500
{
cf8f08631c8e Added ec_slave_config_find_sdo_request().
Florian Pose <fp@igh-essen.com>
parents: 1332
diff changeset
   501
    ec_sdo_request_t *req;
cf8f08631c8e Added ec_slave_config_find_sdo_request().
Florian Pose <fp@igh-essen.com>
parents: 1332
diff changeset
   502
cf8f08631c8e Added ec_slave_config_find_sdo_request().
Florian Pose <fp@igh-essen.com>
parents: 1332
diff changeset
   503
    list_for_each_entry(req, &sc->sdo_requests, list) {
cf8f08631c8e Added ec_slave_config_find_sdo_request().
Florian Pose <fp@igh-essen.com>
parents: 1332
diff changeset
   504
        if (pos--)
cf8f08631c8e Added ec_slave_config_find_sdo_request().
Florian Pose <fp@igh-essen.com>
parents: 1332
diff changeset
   505
            continue;
cf8f08631c8e Added ec_slave_config_find_sdo_request().
Florian Pose <fp@igh-essen.com>
parents: 1332
diff changeset
   506
        return req;
cf8f08631c8e Added ec_slave_config_find_sdo_request().
Florian Pose <fp@igh-essen.com>
parents: 1332
diff changeset
   507
    }
cf8f08631c8e Added ec_slave_config_find_sdo_request().
Florian Pose <fp@igh-essen.com>
parents: 1332
diff changeset
   508
cf8f08631c8e Added ec_slave_config_find_sdo_request().
Florian Pose <fp@igh-essen.com>
parents: 1332
diff changeset
   509
    return NULL;
cf8f08631c8e Added ec_slave_config_find_sdo_request().
Florian Pose <fp@igh-essen.com>
parents: 1332
diff changeset
   510
}
cf8f08631c8e Added ec_slave_config_find_sdo_request().
Florian Pose <fp@igh-essen.com>
parents: 1332
diff changeset
   511
cf8f08631c8e Added ec_slave_config_find_sdo_request().
Florian Pose <fp@igh-essen.com>
parents: 1332
diff changeset
   512
/*****************************************************************************/
cf8f08631c8e Added ec_slave_config_find_sdo_request().
Florian Pose <fp@igh-essen.com>
parents: 1332
diff changeset
   513
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   514
/** Finds a register handler via its position in the list.
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   515
 *
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   516
 * \return Search result, or NULL.
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   517
 */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   518
ec_reg_request_t *ec_slave_config_find_reg_request(
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   519
        ec_slave_config_t *sc, /**< Slave configuration. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   520
        unsigned int pos /**< Position in the list. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   521
        )
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   522
{
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   523
    ec_reg_request_t *reg;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   524
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   525
    list_for_each_entry(reg, &sc->reg_requests, list) {
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   526
        if (pos--)
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   527
            continue;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   528
        return reg;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   529
    }
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   530
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   531
    return NULL;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   532
}
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   533
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   534
/*****************************************************************************/
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   535
1351
cf8f08631c8e Added ec_slave_config_find_sdo_request().
Florian Pose <fp@igh-essen.com>
parents: 1332
diff changeset
   536
/** Finds a VoE handler via its position in the list.
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   537
 *
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   538
 * \return Search result, or NULL.
1351
cf8f08631c8e Added ec_slave_config_find_sdo_request().
Florian Pose <fp@igh-essen.com>
parents: 1332
diff changeset
   539
 */
1263
f44720defbc5 Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents: 1215
diff changeset
   540
ec_voe_handler_t *ec_slave_config_find_voe_handler(
f44720defbc5 Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents: 1215
diff changeset
   541
        ec_slave_config_t *sc, /**< Slave configuration. */
f44720defbc5 Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents: 1215
diff changeset
   542
        unsigned int pos /**< Position in the list. */
f44720defbc5 Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents: 1215
diff changeset
   543
        )
f44720defbc5 Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents: 1215
diff changeset
   544
{
f44720defbc5 Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents: 1215
diff changeset
   545
    ec_voe_handler_t *voe;
f44720defbc5 Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents: 1215
diff changeset
   546
f44720defbc5 Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents: 1215
diff changeset
   547
    list_for_each_entry(voe, &sc->voe_handlers, list) {
f44720defbc5 Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents: 1215
diff changeset
   548
        if (pos--)
f44720defbc5 Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents: 1215
diff changeset
   549
            continue;
f44720defbc5 Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents: 1215
diff changeset
   550
        return voe;
f44720defbc5 Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents: 1215
diff changeset
   551
    }
f44720defbc5 Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents: 1215
diff changeset
   552
f44720defbc5 Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents: 1215
diff changeset
   553
    return NULL;
f44720defbc5 Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents: 1215
diff changeset
   554
}
f44720defbc5 Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents: 1215
diff changeset
   555
2620
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   556
/*****************************************************************************/
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   557
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   558
/** Expires any requests that have been started on a detached slave.
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   559
 */
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   560
void ec_slave_config_expire_disconnected_requests(
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   561
        ec_slave_config_t *sc /**< Slave configuration. */
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   562
        )
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   563
{
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   564
    ec_sdo_request_t *sdo_req;
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   565
    ec_reg_request_t *reg_req;
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   566
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   567
    if (sc->slave) { return; }
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   568
    
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   569
    list_for_each_entry(sdo_req, &sc->sdo_requests, list) {
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   570
        if (sdo_req->state == EC_INT_REQUEST_QUEUED ||
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   571
                sdo_req->state == EC_INT_REQUEST_BUSY) {
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   572
            EC_CONFIG_DBG(sc, 1, "Aborting SDO request; no slave attached.\n");
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   573
            sdo_req->state = EC_INT_REQUEST_FAILURE;
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   574
        }
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   575
    }
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   576
    
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   577
    list_for_each_entry(reg_req, &sc->reg_requests, list) {
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   578
        if (reg_req->state == EC_INT_REQUEST_QUEUED ||
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   579
                reg_req->state == EC_INT_REQUEST_BUSY) {
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   580
            EC_CONFIG_DBG(sc, 1, "Aborting register request; no slave attached.\n");
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   581
            reg_req->state = EC_INT_REQUEST_FAILURE;
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   582
        }
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   583
    }
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   584
}
0e4d098db815 Abort requests started for slave_configs that don't have any actual slaves.
Gavin Lambert <gavinl@compacsort.com>
parents: 2619
diff changeset
   585
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   586
/******************************************************************************
1392
8fcc1d0987c1 DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   587
 *  Application interface
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   588
 *****************************************************************************/
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   589
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   590
int ecrt_slave_config_sync_manager(ec_slave_config_t *sc, uint8_t sync_index,
1509
a864688e7de5 Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents: 1507
diff changeset
   591
        ec_direction_t dir, ec_watchdog_mode_t watchdog_mode)
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   592
{
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   593
    ec_sync_config_t *sync_config;
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   594
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   595
    EC_CONFIG_DBG(sc, 1, "ecrt_slave_config_sync_manager(sc = 0x%p,"
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   596
            " sync_index = %u, dir = %i, watchdog_mode = %i)\n",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   597
            sc, sync_index, dir, watchdog_mode);
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   598
1082
ff06c58e269c Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   599
    if (sync_index >= EC_MAX_SYNC_MANAGERS) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   600
        EC_CONFIG_ERR(sc, "Invalid sync manager index %u!\n", sync_index);
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   601
        return -ENOENT;
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   602
    }
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   603
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   604
    if (dir != EC_DIR_OUTPUT && dir != EC_DIR_INPUT) {
1931
831f2d34664c Fixed format specifiers.
Florian Pose <fp@igh-essen.com>
parents: 1921
diff changeset
   605
        EC_CONFIG_ERR(sc, "Invalid direction %u!\n", (unsigned int) dir);
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   606
        return -EINVAL;
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   607
    }
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   608
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   609
    sync_config = &sc->sync_configs[sync_index];
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   610
    sync_config->dir = dir;
1509
a864688e7de5 Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents: 1507
diff changeset
   611
    sync_config->watchdog_mode = watchdog_mode;
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   612
    return 0;
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   613
}
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   614
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   615
/*****************************************************************************/
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   616
1509
a864688e7de5 Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents: 1507
diff changeset
   617
void ecrt_slave_config_watchdog(ec_slave_config_t *sc,
a864688e7de5 Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents: 1507
diff changeset
   618
        uint16_t divider, uint16_t intervals)
a864688e7de5 Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents: 1507
diff changeset
   619
{
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   620
    EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, divider = %u, intervals = %u)\n",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   621
            __func__, sc, divider, intervals);
1509
a864688e7de5 Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents: 1507
diff changeset
   622
a864688e7de5 Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents: 1507
diff changeset
   623
    sc->watchdog_divider = divider;
a864688e7de5 Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents: 1507
diff changeset
   624
    sc->watchdog_intervals = intervals;
a864688e7de5 Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents: 1507
diff changeset
   625
}
a864688e7de5 Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents: 1507
diff changeset
   626
a864688e7de5 Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents: 1507
diff changeset
   627
/*****************************************************************************/
a864688e7de5 Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents: 1507
diff changeset
   628
2609
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   629
void ecrt_slave_config_overlapping_pdos(ec_slave_config_t *sc,
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   630
        uint8_t allow_overlapping_pdos )
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   631
{
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   632
    EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, allow_overlapping_pdos = %u)\n",
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   633
                __func__, sc, allow_overlapping_pdos);
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   634
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   635
    sc->allow_overlapping_pdos = allow_overlapping_pdos;
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   636
}
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   637
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   638
/*****************************************************************************/
777d1a8b3a27 Integrate skeleton of allow_overlapping_pdos from af21f0bdc7c9
Dave Page <dave.page@gleeble.com>
parents: 2589
diff changeset
   639
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   640
int ecrt_slave_config_pdo_assign_add(ec_slave_config_t *sc,
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   641
        uint8_t sync_index, uint16_t pdo_index)
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   642
{
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   643
    ec_pdo_t *pdo;
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   644
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   645
    EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, sync_index = %u, "
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   646
            "pdo_index = 0x%04X)\n", __func__, sc, sync_index, pdo_index);
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   647
1082
ff06c58e269c Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   648
    if (sync_index >= EC_MAX_SYNC_MANAGERS) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   649
        EC_CONFIG_ERR(sc, "Invalid sync manager index %u!\n", sync_index);
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   650
        return -EINVAL;
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   651
    }
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   652
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   653
    down(&sc->master->master_sem);
1075
94c6e36e0f8d Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents: 1059
diff changeset
   654
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   655
    pdo = ec_pdo_list_add_pdo(&sc->sync_configs[sync_index].pdos, pdo_index);
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   656
    if (IS_ERR(pdo)) {
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   657
        up(&sc->master->master_sem);
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   658
        return PTR_ERR(pdo);
1075
94c6e36e0f8d Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents: 1059
diff changeset
   659
    }
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   660
    pdo->sync_index = sync_index;
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   661
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   662
    ec_slave_config_load_default_mapping(sc, pdo);
1075
94c6e36e0f8d Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents: 1059
diff changeset
   663
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   664
    up(&sc->master->master_sem);
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   665
    return 0;
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   666
}
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   667
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   668
/*****************************************************************************/
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   669
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   670
void ecrt_slave_config_pdo_assign_clear(ec_slave_config_t *sc,
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   671
        uint8_t sync_index)
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   672
{
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   673
    EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, sync_index = %u)\n",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   674
            __func__, sc, sync_index);
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   675
1082
ff06c58e269c Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   676
    if (sync_index >= EC_MAX_SYNC_MANAGERS) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   677
        EC_CONFIG_ERR(sc, "Invalid sync manager index %u!\n", sync_index);
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   678
        return;
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   679
    }
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   680
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   681
    down(&sc->master->master_sem);
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   682
    ec_pdo_list_clear_pdos(&sc->sync_configs[sync_index].pdos);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   683
    up(&sc->master->master_sem);
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   684
}
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   685
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   686
/*****************************************************************************/
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   687
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   688
int ecrt_slave_config_pdo_mapping_add(ec_slave_config_t *sc,
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   689
        uint16_t pdo_index, uint16_t entry_index, uint8_t entry_subindex,
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   690
        uint8_t entry_bit_length)
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   691
{
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   692
    uint8_t sync_index;
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   693
    ec_pdo_t *pdo = NULL;
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   694
    ec_pdo_entry_t *entry;
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   695
    int retval = 0;
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   696
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   697
    EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, "
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   698
            "pdo_index = 0x%04X, entry_index = 0x%04X, "
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   699
            "entry_subindex = 0x%02X, entry_bit_length = %u)\n",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   700
            __func__, sc, pdo_index, entry_index, entry_subindex,
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   701
            entry_bit_length);
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   702
1082
ff06c58e269c Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   703
    for (sync_index = 0; sync_index < EC_MAX_SYNC_MANAGERS; sync_index++)
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   704
        if ((pdo = ec_pdo_list_find_pdo(
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   705
                        &sc->sync_configs[sync_index].pdos, pdo_index)))
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   706
            break;
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   707
1075
94c6e36e0f8d Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents: 1059
diff changeset
   708
    if (pdo) {
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   709
        down(&sc->master->master_sem);
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   710
        entry = ec_pdo_add_entry(pdo, entry_index, entry_subindex,
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   711
                entry_bit_length);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   712
        up(&sc->master->master_sem);
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   713
        if (IS_ERR(entry))
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   714
            retval = PTR_ERR(entry);
1075
94c6e36e0f8d Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents: 1059
diff changeset
   715
    } else {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   716
        EC_CONFIG_ERR(sc, "PDO 0x%04X is not assigned.\n", pdo_index);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   717
        retval = -ENOENT;
1075
94c6e36e0f8d Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents: 1059
diff changeset
   718
    }
94c6e36e0f8d Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents: 1059
diff changeset
   719
94c6e36e0f8d Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents: 1059
diff changeset
   720
    return retval;
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   721
}
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   722
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   723
/*****************************************************************************/
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   724
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   725
void ecrt_slave_config_pdo_mapping_clear(ec_slave_config_t *sc,
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   726
        uint16_t pdo_index)
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   727
{
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   728
    uint8_t sync_index;
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   729
    ec_pdo_t *pdo = NULL;
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   730
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   731
    EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, pdo_index = 0x%04X)\n",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   732
            __func__, sc, pdo_index);
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   733
1082
ff06c58e269c Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   734
    for (sync_index = 0; sync_index < EC_MAX_SYNC_MANAGERS; sync_index++)
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   735
        if ((pdo = ec_pdo_list_find_pdo(
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   736
                        &sc->sync_configs[sync_index].pdos, pdo_index)))
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   737
            break;
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   738
1075
94c6e36e0f8d Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents: 1059
diff changeset
   739
    if (pdo) {
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   740
        down(&sc->master->master_sem);
1075
94c6e36e0f8d Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents: 1059
diff changeset
   741
        ec_pdo_clear_entries(pdo);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   742
        up(&sc->master->master_sem);
1075
94c6e36e0f8d Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents: 1059
diff changeset
   743
    } else {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   744
        EC_CONFIG_WARN(sc, "PDO 0x%04X is not assigned.\n", pdo_index);
1075
94c6e36e0f8d Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents: 1059
diff changeset
   745
    }
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   746
}
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   747
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   748
/*****************************************************************************/
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   749
1082
ff06c58e269c Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   750
int ecrt_slave_config_pdos(ec_slave_config_t *sc,
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   751
        unsigned int n_syncs, const ec_sync_info_t syncs[])
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   752
{
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   753
    int ret;
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   754
    unsigned int i, j, k;
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   755
    const ec_sync_info_t *sync_info;
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   756
    const ec_pdo_info_t *pdo_info;
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   757
    const ec_pdo_entry_info_t *entry_info;
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   758
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   759
    EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, n_syncs = %u, syncs = 0x%p)\n",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   760
            __func__, sc, n_syncs, syncs);
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   761
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   762
    if (!syncs)
1054
4c16fe64b403 Return out of ecrt_slave_config_pdos() when pdo_infos == NULL
Richard Hacker <ha@igh-essen.com>
parents: 1025
diff changeset
   763
        return 0;
4c16fe64b403 Return out of ecrt_slave_config_pdos() when pdo_infos == NULL
Richard Hacker <ha@igh-essen.com>
parents: 1025
diff changeset
   764
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   765
    for (i = 0; i < n_syncs; i++) {
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   766
        sync_info = &syncs[i];
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   767
1097
f974ced181f3 Using EC_END.
Florian Pose <fp@igh-essen.com>
parents: 1092
diff changeset
   768
        if (sync_info->index == (uint8_t) EC_END)
878
40c379697ebf Introduced EC_MAP_END.
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   769
            break;
40c379697ebf Introduced EC_MAP_END.
Florian Pose <fp@igh-essen.com>
parents: 859
diff changeset
   770
1082
ff06c58e269c Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   771
        if (sync_info->index >= EC_MAX_SYNC_MANAGERS) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   772
            EC_CONFIG_ERR(sc, "Invalid sync manager index %u!\n",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   773
                    sync_info->index);
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   774
            return -ENOENT;
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   775
        }
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   776
1509
a864688e7de5 Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents: 1507
diff changeset
   777
        ret = ecrt_slave_config_sync_manager(sc, sync_info->index,
a864688e7de5 Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents: 1507
diff changeset
   778
                sync_info->dir, sync_info->watchdog_mode);
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   779
        if (ret)
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   780
            return ret;
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
   781
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   782
        if (sync_info->n_pdos && sync_info->pdos) {
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   783
            ecrt_slave_config_pdo_assign_clear(sc, sync_info->index);
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   784
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   785
            for (j = 0; j < sync_info->n_pdos; j++) {
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   786
                pdo_info = &sync_info->pdos[j];
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   787
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   788
                ret = ecrt_slave_config_pdo_assign_add(
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   789
                        sc, sync_info->index, pdo_info->index);
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   790
                if (ret)
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   791
                    return ret;
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   792
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   793
                if (pdo_info->n_entries && pdo_info->entries) {
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   794
                    ecrt_slave_config_pdo_mapping_clear(sc, pdo_info->index);
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   795
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   796
                    for (k = 0; k < pdo_info->n_entries; k++) {
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   797
                        entry_info = &pdo_info->entries[k];
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   798
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   799
                        ret = ecrt_slave_config_pdo_mapping_add(sc,
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   800
                                pdo_info->index, entry_info->index,
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   801
                                entry_info->subindex,
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   802
                                entry_info->bit_length);
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   803
                        if (ret)
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   804
                            return ret;
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   805
                    }
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   806
                }
842
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   807
            }
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   808
        }
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   809
    }
40e27e5a8dce Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   810
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   811
    return 0;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   812
}
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   813
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   814
/*****************************************************************************/
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   815
807
f8bca95ab75d Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents: 797
diff changeset
   816
int ecrt_slave_config_reg_pdo_entry(
923
a6b51990e7e6 Changed Pdo entry registration function - return byte and bit positions
Richard Hacker <ha@igh-essen.com>
parents: 916
diff changeset
   817
        ec_slave_config_t *sc,
a6b51990e7e6 Changed Pdo entry registration function - return byte and bit positions
Richard Hacker <ha@igh-essen.com>
parents: 916
diff changeset
   818
        uint16_t index,
a6b51990e7e6 Changed Pdo entry registration function - return byte and bit positions
Richard Hacker <ha@igh-essen.com>
parents: 916
diff changeset
   819
        uint8_t subindex,
a6b51990e7e6 Changed Pdo entry registration function - return byte and bit positions
Richard Hacker <ha@igh-essen.com>
parents: 916
diff changeset
   820
        ec_domain_t *domain,
925
939f3e9bba1e Some improvements concerning bit_position.
Florian Pose <fp@igh-essen.com>
parents: 924
diff changeset
   821
        unsigned int *bit_position
916
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 893
diff changeset
   822
        )
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 893
diff changeset
   823
{
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   824
    uint8_t sync_index;
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   825
    const ec_sync_config_t *sync_config;
925
939f3e9bba1e Some improvements concerning bit_position.
Florian Pose <fp@igh-essen.com>
parents: 924
diff changeset
   826
    unsigned int bit_offset, bit_pos;
807
f8bca95ab75d Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents: 797
diff changeset
   827
    ec_pdo_t *pdo;
f8bca95ab75d Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents: 797
diff changeset
   828
    ec_pdo_entry_t *entry;
923
a6b51990e7e6 Changed Pdo entry registration function - return byte and bit positions
Richard Hacker <ha@igh-essen.com>
parents: 916
diff changeset
   829
    int sync_offset;
807
f8bca95ab75d Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents: 797
diff changeset
   830
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   831
    EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, index = 0x%04X, "
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   832
            "subindex = 0x%02X, domain = 0x%p, bit_position = 0x%p)\n",
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   833
            __func__, sc, index, subindex, domain, bit_position);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   834
1082
ff06c58e269c Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   835
    for (sync_index = 0; sync_index < EC_MAX_SYNC_MANAGERS; sync_index++) {
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   836
        sync_config = &sc->sync_configs[sync_index];
807
f8bca95ab75d Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents: 797
diff changeset
   837
        bit_offset = 0;
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   838
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   839
        list_for_each_entry(pdo, &sync_config->pdos.list, list) {
807
f8bca95ab75d Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents: 797
diff changeset
   840
            list_for_each_entry(entry, &pdo->entries, list) {
f8bca95ab75d Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents: 797
diff changeset
   841
                if (entry->index != index || entry->subindex != subindex) {
f8bca95ab75d Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents: 797
diff changeset
   842
                    bit_offset += entry->bit_length;
f8bca95ab75d Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents: 797
diff changeset
   843
                } else {
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   844
                    bit_pos = bit_offset % 8;
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   845
                    if (bit_position) {
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   846
                        *bit_position = bit_pos;
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   847
                    } else if (bit_pos) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   848
                        EC_CONFIG_ERR(sc, "PDO entry 0x%04X:%02X does"
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   849
                                " not byte-align.\n", index, subindex);
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   850
                        return -EFAULT;
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   851
                    }
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
   852
1075
94c6e36e0f8d Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents: 1059
diff changeset
   853
                    sync_offset = ec_slave_config_prepare_fmmu(
94c6e36e0f8d Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents: 1059
diff changeset
   854
                            sc, domain, sync_index, sync_config->dir);
94c6e36e0f8d Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents: 1059
diff changeset
   855
                    if (sync_offset < 0)
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   856
                        return sync_offset;
1075
94c6e36e0f8d Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents: 1059
diff changeset
   857
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   858
                    return sync_offset + bit_offset / 8;
807
f8bca95ab75d Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents: 797
diff changeset
   859
                }
f8bca95ab75d Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents: 797
diff changeset
   860
            }
f8bca95ab75d Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents: 797
diff changeset
   861
        }
f8bca95ab75d Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents: 797
diff changeset
   862
    }
f8bca95ab75d Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents: 797
diff changeset
   863
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   864
    EC_CONFIG_ERR(sc, "PDO entry 0x%04X:%02X is not mapped.\n",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   865
           index, subindex);
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   866
    return -ENOENT;
924
d8d9a1056afa Fixed missing right brace
Richard Hacker <ha@igh-essen.com>
parents: 923
diff changeset
   867
}
923
a6b51990e7e6 Changed Pdo entry registration function - return byte and bit positions
Richard Hacker <ha@igh-essen.com>
parents: 916
diff changeset
   868
1392
8fcc1d0987c1 DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   869
/*****************************************************************************/
8fcc1d0987c1 DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   870
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   871
int ecrt_slave_config_reg_pdo_entry_pos(
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   872
        ec_slave_config_t *sc,
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   873
        uint8_t sync_index,
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   874
        unsigned int pdo_pos,
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   875
        unsigned int entry_pos,
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   876
        ec_domain_t *domain,
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   877
        unsigned int *bit_position
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   878
        )
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   879
{
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   880
    const ec_sync_config_t *sync_config;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   881
    unsigned int bit_offset, pp, ep;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   882
    ec_pdo_t *pdo;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   883
    ec_pdo_entry_t *entry;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   884
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   885
    EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, sync_index = %u, pdo_pos = %u,"
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   886
            " entry_pos = %u, domain = 0x%p, bit_position = 0x%p)\n",
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   887
            __func__, sc, sync_index, pdo_pos, entry_pos,
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   888
            domain, bit_position);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   889
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   890
    if (sync_index >= EC_MAX_SYNC_MANAGERS) {
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   891
        EC_CONFIG_ERR(sc, "Invalid syncmanager position %u.\n", sync_index);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   892
        return -EINVAL;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   893
    }
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   894
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   895
    sync_config = &sc->sync_configs[sync_index];
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   896
    bit_offset = 0;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   897
    pp = 0;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   898
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   899
    list_for_each_entry(pdo, &sync_config->pdos.list, list) {
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   900
        ep = 0;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   901
        list_for_each_entry(entry, &pdo->entries, list) {
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   902
            if (pp != pdo_pos || ep != entry_pos) {
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   903
                bit_offset += entry->bit_length;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   904
            } else {
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   905
                unsigned int bit_pos = bit_offset % 8;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   906
                int sync_offset;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   907
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   908
                if (bit_position) {
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   909
                    *bit_position = bit_pos;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   910
                } else if (bit_pos) {
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   911
                    EC_CONFIG_ERR(sc, "PDO entry 0x%04X:%02X does"
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   912
                            " not byte-align.\n",
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   913
                            pdo->index, entry->subindex);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   914
                    return -EFAULT;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   915
                }
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   916
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   917
                sync_offset = ec_slave_config_prepare_fmmu(
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   918
                        sc, domain, sync_index, sync_config->dir);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   919
                if (sync_offset < 0)
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   920
                    return sync_offset;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   921
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   922
                return sync_offset + bit_offset / 8;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   923
            }
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   924
            ep++;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   925
        }
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   926
        pp++;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   927
    }
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   928
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   929
    EC_CONFIG_ERR(sc, "PDO entry specification %u/%u/%u out of range.\n",
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   930
           sync_index, pdo_pos, entry_pos);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   931
    return -ENOENT;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   932
}
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   933
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   934
/*****************************************************************************/
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   935
1448
d7ba0c408a07 Merged ecrt_slave_config_dc_assign_activate() and
Florian Pose <fp@igh-essen.com>
parents: 1438
diff changeset
   936
void ecrt_slave_config_dc(ec_slave_config_t *sc, uint16_t assign_activate,
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   937
        uint32_t sync0_cycle_time, int32_t sync0_shift_time,
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   938
        uint32_t sync1_cycle_time, int32_t sync1_shift_time)
1438
1d30b96bb04f Replaced ecrt_slave_config_dc_cycle_times() and ecrt_slave_config_dc_shift_times() by ecrt_slave_config_dc_sync_signals().
Florian Pose <fp@igh-essen.com>
parents: 1412
diff changeset
   939
{
1933
d11036537092 Added debug output for ecrt_slave_config_dc().
Florian Pose <fp@igh-essen.com>
parents: 1931
diff changeset
   940
    EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, assign_activate = 0x%04X,"
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   941
            " sync0_cycle = %u, sync0_shift = %i,"
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   942
            " sync1_cycle = %u, sync1_shift = %i\n",
1933
d11036537092 Added debug output for ecrt_slave_config_dc().
Florian Pose <fp@igh-essen.com>
parents: 1931
diff changeset
   943
            __func__, sc, assign_activate, sync0_cycle_time, sync0_shift_time,
d11036537092 Added debug output for ecrt_slave_config_dc().
Florian Pose <fp@igh-essen.com>
parents: 1931
diff changeset
   944
            sync1_cycle_time, sync1_shift_time);
d11036537092 Added debug output for ecrt_slave_config_dc().
Florian Pose <fp@igh-essen.com>
parents: 1931
diff changeset
   945
1507
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   946
    sc->dc_assign_activate = assign_activate;
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   947
    sc->dc_sync[0].cycle_time = sync0_cycle_time;
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   948
    sc->dc_sync[0].shift_time = sync0_shift_time;
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   949
    sc->dc_sync[1].cycle_time = sync1_cycle_time;
68e89abadd19 Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1448
diff changeset
   950
    sc->dc_sync[1].shift_time = sync1_shift_time;
1412
8f7bbbd3b7ac DC shift time working.
Florian Pose <fp@igh-essen.com>
parents: 1392
diff changeset
   951
}
8f7bbbd3b7ac DC shift time working.
Florian Pose <fp@igh-essen.com>
parents: 1392
diff changeset
   952
8f7bbbd3b7ac DC shift time working.
Florian Pose <fp@igh-essen.com>
parents: 1392
diff changeset
   953
/*****************************************************************************/
8f7bbbd3b7ac DC shift time working.
Florian Pose <fp@igh-essen.com>
parents: 1392
diff changeset
   954
893
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   955
int ecrt_slave_config_sdo(ec_slave_config_t *sc, uint16_t index,
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   956
        uint8_t subindex, const uint8_t *data, size_t size)
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   957
{
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   958
    ec_slave_t *slave = sc->slave;
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   959
    ec_sdo_request_t *req;
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   960
    int ret;
893
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   961
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   962
    EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, index = 0x%04X, "
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   963
            "subindex = 0x%02X, data = 0x%p, size = %zu)\n",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   964
            __func__, sc, index, subindex, data, size);
1115
b7b965ab94cd Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents: 1097
diff changeset
   965
893
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   966
    if (slave && !(slave->sii.mailbox_protocols & EC_MBOX_COE)) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   967
        EC_CONFIG_WARN(sc, "Attached slave does not support CoE!\n");
893
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   968
    }
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   969
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   970
    if (!(req = (ec_sdo_request_t *)
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   971
          kmalloc(sizeof(ec_sdo_request_t), GFP_KERNEL))) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   972
        EC_CONFIG_ERR(sc, "Failed to allocate memory for"
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
   973
                " SDO configuration!\n");
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   974
        return -ENOMEM;
893
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   975
    }
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   976
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   977
    ec_sdo_request_init(req);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   978
    ecrt_sdo_request_index(req, index, subindex);
893
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   979
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   980
    ret = ec_sdo_request_copy_data(req, data, size);
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   981
    if (ret < 0) {
893
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   982
        ec_sdo_request_clear(req);
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   983
        kfree(req);
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
   984
        return ret;
893
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   985
    }
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   986
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   987
    down(&sc->master->master_sem);
893
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   988
    list_add_tail(&req->list, &sc->sdo_configs);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
   989
    up(&sc->master->master_sem);
893
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   990
    return 0;
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   991
}
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   992
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   993
/*****************************************************************************/
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   994
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
   995
int ecrt_slave_config_sdo8(ec_slave_config_t *sc, uint16_t index,
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   996
        uint8_t subindex, uint8_t value)
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   997
{
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   998
    uint8_t data[1];
1115
b7b965ab94cd Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents: 1097
diff changeset
   999
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1000
    EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, index = 0x%04X, "
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1001
            "subindex = 0x%02X, value = %u)\n",
1931
831f2d34664c Fixed format specifiers.
Florian Pose <fp@igh-essen.com>
parents: 1921
diff changeset
  1002
            __func__, sc, index, subindex, (unsigned int) value);
1115
b7b965ab94cd Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents: 1097
diff changeset
  1003
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1004
    EC_WRITE_U8(data, value);
893
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
  1005
    return ecrt_slave_config_sdo(sc, index, subindex, data, 1);
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
  1006
}
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
  1007
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
  1008
/*****************************************************************************/
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
  1009
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
  1010
int ecrt_slave_config_sdo16(ec_slave_config_t *sc, uint16_t index,
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1011
        uint8_t subindex, uint16_t value)
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1012
{
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1013
    uint8_t data[2];
1115
b7b965ab94cd Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents: 1097
diff changeset
  1014
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1015
    EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, index = 0x%04X, "
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1016
            "subindex = 0x%02X, value = %u)\n",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1017
            __func__, sc, index, subindex, value);
1115
b7b965ab94cd Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents: 1097
diff changeset
  1018
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1019
    EC_WRITE_U16(data, value);
893
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
  1020
    return ecrt_slave_config_sdo(sc, index, subindex, data, 2);
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
  1021
}
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
  1022
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
  1023
/*****************************************************************************/
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
  1024
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
  1025
int ecrt_slave_config_sdo32(ec_slave_config_t *sc, uint16_t index,
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1026
        uint8_t subindex, uint32_t value)
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1027
{
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1028
    uint8_t data[4];
1115
b7b965ab94cd Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents: 1097
diff changeset
  1029
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1030
    EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, index = 0x%04X, "
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1031
            "subindex = 0x%02X, value = %u)\n",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1032
            __func__, sc, index, subindex, value);
1115
b7b965ab94cd Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents: 1097
diff changeset
  1033
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1034
    EC_WRITE_U32(data, value);
893
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
  1035
    return ecrt_slave_config_sdo(sc, index, subindex, data, 4);
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1036
}
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1037
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1038
/*****************************************************************************/
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1039
1526
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1040
int ecrt_slave_config_complete_sdo(ec_slave_config_t *sc, uint16_t index,
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1041
        const uint8_t *data, size_t size)
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1042
{
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1043
    ec_slave_t *slave = sc->slave;
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1044
    ec_sdo_request_t *req;
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1045
    int ret;
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1046
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1047
    EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, index = 0x%04X, "
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1048
            "data = 0x%p, size = %zu)\n", __func__, sc, index, data, size);
1526
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1049
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1050
    if (slave && !(slave->sii.mailbox_protocols & EC_MBOX_COE)) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1051
        EC_CONFIG_WARN(sc, "Attached slave does not support CoE!\n");
1526
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1052
    }
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1053
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1054
    if (!(req = (ec_sdo_request_t *)
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1055
          kmalloc(sizeof(ec_sdo_request_t), GFP_KERNEL))) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1056
        EC_CONFIG_ERR(sc, "Failed to allocate memory for"
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1057
                " SDO configuration!\n");
1526
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1058
        return -ENOMEM;
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1059
    }
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1060
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1061
    ec_sdo_request_init(req);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1062
    ecrt_sdo_request_index(req, index, 0);
1526
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1063
    req->complete_access = 1;
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1064
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1065
    ret = ec_sdo_request_copy_data(req, data, size);
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1066
    if (ret < 0) {
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1067
        ec_sdo_request_clear(req);
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1068
        kfree(req);
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1069
        return ret;
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1070
    }
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1071
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1072
    down(&sc->master->master_sem);
1526
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1073
    list_add_tail(&req->list, &sc->sdo_configs);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1074
    up(&sc->master->master_sem);
1526
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1075
    return 0;
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1076
}
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1077
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1078
/*****************************************************************************/
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1079
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1080
int ecrt_slave_config_emerg_size(ec_slave_config_t *sc, size_t elements)
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1081
{
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1082
    return ec_coe_emerg_ring_size(&sc->emerg_ring, elements);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1083
}
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1084
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1085
/*****************************************************************************/
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1086
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1087
int ecrt_slave_config_emerg_pop(ec_slave_config_t *sc, uint8_t *target)
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1088
{
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1089
    return ec_coe_emerg_ring_pop(&sc->emerg_ring, target);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1090
}
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1091
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1092
/*****************************************************************************/
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1093
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1094
int ecrt_slave_config_emerg_clear(ec_slave_config_t *sc)
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1095
{
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1096
    return ec_coe_emerg_ring_clear_ring(&sc->emerg_ring);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1097
}
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1098
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1099
/*****************************************************************************/
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1100
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1101
int ecrt_slave_config_emerg_overruns(ec_slave_config_t *sc)
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1102
{
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1103
    return ec_coe_emerg_ring_overruns(&sc->emerg_ring);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1104
}
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1105
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1106
/*****************************************************************************/
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1107
1332
d62633fea8ed merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
  1108
/** Same as ecrt_slave_config_create_sdo_request(), but with ERR_PTR() return
d62633fea8ed merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
  1109
 * value.
d62633fea8ed merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
  1110
 */
1312
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1111
ec_sdo_request_t *ecrt_slave_config_create_sdo_request_err(
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1112
        ec_slave_config_t *sc, uint16_t index, uint8_t subindex, size_t size)
858
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
  1113
{
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
  1114
    ec_sdo_request_t *req;
1312
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1115
    int ret;
858
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
  1116
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1117
    EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, "
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1118
            "index = 0x%04X, subindex = 0x%02X, size = %zu)\n",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1119
            __func__, sc, index, subindex, size);
1181
9e5954a2a46e Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents: 1178
diff changeset
  1120
858
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
  1121
    if (!(req = (ec_sdo_request_t *)
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
  1122
                kmalloc(sizeof(ec_sdo_request_t), GFP_KERNEL))) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1123
        EC_CONFIG_ERR(sc, "Failed to allocate SDO request memory!\n");
1312
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1124
        return ERR_PTR(-ENOMEM);
858
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
  1125
    }
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
  1126
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
  1127
    ec_sdo_request_init(req);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1128
    ecrt_sdo_request_index(req, index, subindex);
858
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
  1129
1312
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1130
    ret = ec_sdo_request_alloc(req, size);
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1131
    if (ret < 0) {
858
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
  1132
        ec_sdo_request_clear(req);
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
  1133
        kfree(req);
1312
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1134
        return ERR_PTR(ret);
858
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
  1135
    }
859
233e32f428e1 Replaced ec_fsm_coe_\(upload\|download\)() with ec_fsm_coe_transfer();
Florian Pose <fp@igh-essen.com>
parents: 858
diff changeset
  1136
233e32f428e1 Replaced ec_fsm_coe_\(upload\|download\)() with ec_fsm_coe_transfer();
Florian Pose <fp@igh-essen.com>
parents: 858
diff changeset
  1137
    // prepare data for optional writing
233e32f428e1 Replaced ec_fsm_coe_\(upload\|download\)() with ec_fsm_coe_transfer();
Florian Pose <fp@igh-essen.com>
parents: 858
diff changeset
  1138
    memset(req->data, 0x00, size);
233e32f428e1 Replaced ec_fsm_coe_\(upload\|download\)() with ec_fsm_coe_transfer();
Florian Pose <fp@igh-essen.com>
parents: 858
diff changeset
  1139
    req->data_size = size;
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1140
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1141
    down(&sc->master->master_sem);
858
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
  1142
    list_add_tail(&req->list, &sc->sdo_requests);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1143
    up(&sc->master->master_sem);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1144
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1145
    return req;
858
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
  1146
}
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
  1147
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
  1148
/*****************************************************************************/
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
  1149
1312
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1150
ec_sdo_request_t *ecrt_slave_config_create_sdo_request(
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1151
        ec_slave_config_t *sc, uint16_t index, uint8_t subindex, size_t size)
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1152
{
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1153
    ec_sdo_request_t *s = ecrt_slave_config_create_sdo_request_err(sc, index,
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1154
            subindex, size);
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1155
    return IS_ERR(s) ? NULL : s;
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1156
}
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1157
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1158
/*****************************************************************************/
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1159
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1160
/** Same as ecrt_slave_config_create_reg_request(), but with ERR_PTR() return
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1161
 * value.
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1162
 */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1163
ec_reg_request_t *ecrt_slave_config_create_reg_request_err(
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1164
        ec_slave_config_t *sc, size_t size)
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1165
{
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1166
    ec_reg_request_t *reg;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1167
    int ret;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1168
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1169
    EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, size = %zu)\n",
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1170
            __func__, sc, size);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1171
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1172
    if (!(reg = (ec_reg_request_t *)
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1173
                kmalloc(sizeof(ec_reg_request_t), GFP_KERNEL))) {
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1174
        EC_CONFIG_ERR(sc, "Failed to allocate register request memory!\n");
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1175
        return ERR_PTR(-ENOMEM);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1176
    }
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1177
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1178
    ret = ec_reg_request_init(reg, size);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1179
    if (ret) {
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1180
        kfree(reg);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1181
        return ERR_PTR(ret);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1182
    }
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1183
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1184
    down(&sc->master->master_sem);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1185
    list_add_tail(&reg->list, &sc->reg_requests);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1186
    up(&sc->master->master_sem);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1187
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1188
    return reg;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1189
}
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1190
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1191
/*****************************************************************************/
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1192
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1193
ec_reg_request_t *ecrt_slave_config_create_reg_request(
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1194
        ec_slave_config_t *sc, size_t size)
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1195
{
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1196
    ec_reg_request_t *reg =
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1197
        ecrt_slave_config_create_reg_request_err(sc, size);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1198
    return IS_ERR(reg) ? NULL : reg;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1199
}
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1200
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1201
/*****************************************************************************/
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1202
1332
d62633fea8ed merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
  1203
/** Same as ecrt_slave_config_create_voe_handler(), but with ERR_PTR() return
d62633fea8ed merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
  1204
 * value.
d62633fea8ed merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
  1205
 */
1312
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1206
ec_voe_handler_t *ecrt_slave_config_create_voe_handler_err(
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1207
        ec_slave_config_t *sc, size_t size)
1209
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
  1208
{
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
  1209
    ec_voe_handler_t *voe;
1312
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1210
    int ret;
1209
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
  1211
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1212
    EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, size = %zu)\n", __func__, sc, size);
1209
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
  1213
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
  1214
    if (!(voe = (ec_voe_handler_t *)
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
  1215
                kmalloc(sizeof(ec_voe_handler_t), GFP_KERNEL))) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1216
        EC_CONFIG_ERR(sc, "Failed to allocate VoE request memory!\n");
1312
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1217
        return ERR_PTR(-ENOMEM);
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1218
    }
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1219
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1220
    ret = ec_voe_handler_init(voe, sc, size);
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1221
    if (ret < 0) {
1209
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
  1222
        kfree(voe);
1312
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1223
        return ERR_PTR(ret);
1209
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
  1224
    }
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
  1225
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1226
    down(&sc->master->master_sem);
1209
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
  1227
    list_add_tail(&voe->list, &sc->voe_handlers);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1228
    up(&sc->master->master_sem);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1229
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1230
    return voe;
1209
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
  1231
}
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
  1232
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
  1233
/*****************************************************************************/
8be462afb7f4 Added VoE handler.
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
  1234
1312
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1235
ec_voe_handler_t *ecrt_slave_config_create_voe_handler(
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1236
        ec_slave_config_t *sc, size_t size)
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1237
{
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1238
    ec_voe_handler_t *voe = ecrt_slave_config_create_voe_handler_err(sc,
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1239
            size);
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1240
    return IS_ERR(voe) ? NULL : voe;
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1241
}
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1242
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1243
/*****************************************************************************/
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1277
diff changeset
  1244
1022
8e49b519e6ba Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents: 1010
diff changeset
  1245
void ecrt_slave_config_state(const ec_slave_config_t *sc,
8e49b519e6ba Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents: 1010
diff changeset
  1246
        ec_slave_config_state_t *state)
8e49b519e6ba Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents: 1010
diff changeset
  1247
{
8e49b519e6ba Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents: 1010
diff changeset
  1248
    state->online = sc->slave ? 1 : 0;
8e49b519e6ba Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents: 1010
diff changeset
  1249
    if (state->online) {
8e49b519e6ba Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents: 1010
diff changeset
  1250
        state->operational =
1277
1189e040fe12 merge -c1521 branches/stable-1.4: Fixed race concerning ec_slave_config_state->operational.
Florian Pose <fp@igh-essen.com>
parents: 1263
diff changeset
  1251
            sc->slave->current_state == EC_SLAVE_STATE_OP
1189e040fe12 merge -c1521 branches/stable-1.4: Fixed race concerning ec_slave_config_state->operational.
Florian Pose <fp@igh-essen.com>
parents: 1263
diff changeset
  1252
            && !sc->slave->force_config;
1022
8e49b519e6ba Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents: 1010
diff changeset
  1253
        state->al_state = sc->slave->current_state;
8e49b519e6ba Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents: 1010
diff changeset
  1254
    } else {
8e49b519e6ba Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents: 1010
diff changeset
  1255
        state->operational = 0;
8e49b519e6ba Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents: 1010
diff changeset
  1256
        state->al_state = EC_SLAVE_STATE_UNKNOWN;
8e49b519e6ba Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents: 1010
diff changeset
  1257
    }
8e49b519e6ba Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents: 1010
diff changeset
  1258
}
8e49b519e6ba Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents: 1010
diff changeset
  1259
8e49b519e6ba Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents: 1010
diff changeset
  1260
/*****************************************************************************/
8e49b519e6ba Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents: 1010
diff changeset
  1261
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1262
int ecrt_slave_config_idn(ec_slave_config_t *sc, uint8_t drive_no,
1952
7d9fb723fc4b Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents: 1944
diff changeset
  1263
        uint16_t idn, ec_al_state_t state, const uint8_t *data,
7d9fb723fc4b Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents: 1944
diff changeset
  1264
        size_t size)
1844
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1265
{
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1266
    ec_slave_t *slave = sc->slave;
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1267
    ec_soe_request_t *req;
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1268
    int ret;
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1269
1952
7d9fb723fc4b Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents: 1944
diff changeset
  1270
    EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, drive_no = %u, idn = 0x%04X, "
7d9fb723fc4b Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents: 1944
diff changeset
  1271
            "state = %u, data = 0x%p, size = %zu)\n",
7d9fb723fc4b Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents: 1944
diff changeset
  1272
            __func__, sc, drive_no, idn, state, data, size);
7d9fb723fc4b Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents: 1944
diff changeset
  1273
7d9fb723fc4b Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents: 1944
diff changeset
  1274
    if (drive_no > 7) {
1966
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
  1275
        EC_CONFIG_ERR(sc, "Invalid drive number %u!\n",
23c638a81fe7 Output IDN configuration as part of 'ethercat config -v'.
Florian Pose <fp@igh-essen.com>
parents: 1952
diff changeset
  1276
                (unsigned int) drive_no);
1952
7d9fb723fc4b Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents: 1944
diff changeset
  1277
        return -EINVAL;
7d9fb723fc4b Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents: 1944
diff changeset
  1278
    }
1944
73896ef6d077 Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents: 1933
diff changeset
  1279
73896ef6d077 Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents: 1933
diff changeset
  1280
    if (state != EC_AL_STATE_PREOP && state != EC_AL_STATE_SAFEOP) {
73896ef6d077 Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents: 1933
diff changeset
  1281
        EC_CONFIG_ERR(sc, "AL state for IDN config"
73896ef6d077 Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents: 1933
diff changeset
  1282
                " must be PREOP or SAFEOP!\n");
73896ef6d077 Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents: 1933
diff changeset
  1283
        return -EINVAL;
73896ef6d077 Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents: 1933
diff changeset
  1284
    }
1844
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1285
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1286
    if (slave && !(slave->sii.mailbox_protocols & EC_MBOX_SOE)) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1287
        EC_CONFIG_WARN(sc, "Attached slave does not support SoE!\n");
1844
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1288
    }
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1289
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1290
    if (!(req = (ec_soe_request_t *)
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1291
          kmalloc(sizeof(ec_soe_request_t), GFP_KERNEL))) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1292
        EC_CONFIG_ERR(sc, "Failed to allocate memory for"
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1873
diff changeset
  1293
                " IDN configuration!\n");
1844
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1294
        return -ENOMEM;
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1295
    }
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1296
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1297
    ec_soe_request_init(req);
1952
7d9fb723fc4b Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents: 1944
diff changeset
  1298
    ec_soe_request_set_drive_no(req, drive_no);
1844
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1299
    ec_soe_request_set_idn(req, idn);
1944
73896ef6d077 Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents: 1933
diff changeset
  1300
    req->al_state = state;
1844
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1301
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1302
    ret = ec_soe_request_copy_data(req, data, size);
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1303
    if (ret < 0) {
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1304
        ec_soe_request_clear(req);
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1305
        kfree(req);
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1306
        return ret;
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1307
    }
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1308
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1309
    down(&sc->master->master_sem);
1844
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1310
    list_add_tail(&req->list, &sc->soe_configs);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1311
    up(&sc->master->master_sem);
1844
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1312
    return 0;
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1313
}
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1314
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1315
/*****************************************************************************/
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1316
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1317
/** \cond */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1318
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1054
diff changeset
  1319
EXPORT_SYMBOL(ecrt_slave_config_sync_manager);
1509
a864688e7de5 Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents: 1507
diff changeset
  1320
EXPORT_SYMBOL(ecrt_slave_config_watchdog);
879
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
  1321
EXPORT_SYMBOL(ecrt_slave_config_pdo_assign_add);
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
  1322
EXPORT_SYMBOL(ecrt_slave_config_pdo_assign_clear);
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
  1323
EXPORT_SYMBOL(ecrt_slave_config_pdo_mapping_add);
9b395c5646ab Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents: 878
diff changeset
  1324
EXPORT_SYMBOL(ecrt_slave_config_pdo_mapping_clear);
1082
ff06c58e269c Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
  1325
EXPORT_SYMBOL(ecrt_slave_config_pdos);
807
f8bca95ab75d Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents: 797
diff changeset
  1326
EXPORT_SYMBOL(ecrt_slave_config_reg_pdo_entry);
1448
d7ba0c408a07 Merged ecrt_slave_config_dc_assign_activate() and
Florian Pose <fp@igh-essen.com>
parents: 1438
diff changeset
  1327
EXPORT_SYMBOL(ecrt_slave_config_dc);
893
d921fff3d6e2 Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents: 879
diff changeset
  1328
EXPORT_SYMBOL(ecrt_slave_config_sdo);
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1329
EXPORT_SYMBOL(ecrt_slave_config_sdo8);
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1330
EXPORT_SYMBOL(ecrt_slave_config_sdo16);
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1331
EXPORT_SYMBOL(ecrt_slave_config_sdo32);
1526
66edd310830c Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents: 1509
diff changeset
  1332
EXPORT_SYMBOL(ecrt_slave_config_complete_sdo);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1333
EXPORT_SYMBOL(ecrt_slave_config_emerg_size);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1334
EXPORT_SYMBOL(ecrt_slave_config_emerg_pop);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1335
EXPORT_SYMBOL(ecrt_slave_config_emerg_clear);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1336
EXPORT_SYMBOL(ecrt_slave_config_emerg_overruns);
858
69122084d066 Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents: 854
diff changeset
  1337
EXPORT_SYMBOL(ecrt_slave_config_create_sdo_request);
1215
3bedd338ff76 Added missing export.
Florian Pose <fp@igh-essen.com>
parents: 1209
diff changeset
  1338
EXPORT_SYMBOL(ecrt_slave_config_create_voe_handler);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2411
diff changeset
  1339
EXPORT_SYMBOL(ecrt_slave_config_create_reg_request);
1022
8e49b519e6ba Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents: 1010
diff changeset
  1340
EXPORT_SYMBOL(ecrt_slave_config_state);
1844
b6bd88d4806b Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
  1341
EXPORT_SYMBOL(ecrt_slave_config_idn);
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1342
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1343
/** \endcond */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1344
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1345
/*****************************************************************************/