author | Florian Pose <fp@igh-essen.com> |
Mon, 26 Jan 2009 10:30:17 +0000 | |
changeset 1323 | 10fbef0a3ac5 |
parent 1313 | ed15eef57d5c |
child 1326 | ef907b0b5125 |
permissions | -rw-r--r-- |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
* |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
* |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
* and/or modify it under the terms of the GNU General Public License |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
11 |
* as published by the Free Software Foundation; either version 2 of the |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
* License, or (at your option) any later version. |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
* |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
15 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
* GNU General Public License for more details. |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
18 |
* |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
19 |
* You should have received a copy of the GNU General Public License |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
* |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
23 |
* The right to use EtherCAT Technology is granted and comes free of |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
24 |
* charge under condition of compatibility of product made by |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
25 |
* Licensee. People intending to distribute/sell products based on the |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
26 |
* code, have to sign an agreement to guarantee that products using |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
* software based on IgH EtherCAT master stay compatible with the actual |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
* EtherCAT specification (which are released themselves as an open |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
* standard) as the (only) precondition to have the right to use EtherCAT |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
* Technology, IP and trade marks. |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
* |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
/** |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
\file |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
EtherCAT slave configuration methods. |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
*/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
|
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
990
diff
changeset
|
41 |
#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
|
42 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
#include "globals.h" |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
#include "master.h" |
1209 | 45 |
#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
|
46 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
#include "slave_config.h" |
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 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
/** Slave configuration constructor. |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
* |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
53 |
* 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
|
54 |
* position parameters. |
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
990
diff
changeset
|
55 |
*/ |
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
990
diff
changeset
|
56 |
void ec_slave_config_init( |
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
990
diff
changeset
|
57 |
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
|
58 |
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
|
59 |
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
|
60 |
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
|
61 |
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
|
62 |
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
|
63 |
) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
{ |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
65 |
unsigned int i; |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
66 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
67 |
sc->master = master; |
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; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
72 |
sc->slave = NULL; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
|
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
74 |
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
|
75 |
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
|
76 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
INIT_LIST_HEAD(&sc->sdo_configs); |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
78 |
INIT_LIST_HEAD(&sc->sdo_requests); |
1209 | 79 |
INIT_LIST_HEAD(&sc->voe_handlers); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
80 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
sc->used_fmmus = 0; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
82 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
83 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
85 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
86 |
/** Slave configuration destructor. |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
* |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
* 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
|
89 |
*/ |
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
990
diff
changeset
|
90 |
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
|
91 |
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
|
92 |
) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
{ |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
94 |
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
|
95 |
ec_sdo_request_t *req, *next_req; |
1209 | 96 |
ec_voe_handler_t *voe, *next_voe; |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
|
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
990
diff
changeset
|
98 |
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
|
99 |
|
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
100 |
// 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
|
101 |
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
|
102 |
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
|
103 |
|
814 | 104 |
// 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
|
105 |
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
|
106 |
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
|
107 |
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
|
108 |
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
|
109 |
} |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
|
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
111 |
// free all Sdo requests |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
112 |
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
|
113 |
list_del(&req->list); |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
114 |
ec_sdo_request_clear(req); |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
115 |
kfree(req); |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
116 |
} |
1209 | 117 |
|
118 |
// free all VoE handlers |
|
119 |
list_for_each_entry_safe(voe, next_voe, &sc->voe_handlers, list) { |
|
120 |
list_del(&voe->list); |
|
121 |
ec_voe_handler_clear(voe); |
|
122 |
kfree(voe); |
|
123 |
} |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
124 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
125 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
/** Prepares an FMMU configuration. |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
129 |
* |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
* 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
|
131 |
* 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
|
132 |
* 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
|
133 |
* 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
|
134 |
* 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
|
135 |
* returns with success. |
db73994fbdac
Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents:
893
diff
changeset
|
136 |
* |
db73994fbdac
Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents:
893
diff
changeset
|
137 |
* \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
|
138 |
* \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
|
139 |
*/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
140 |
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
|
141 |
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
|
142 |
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
|
143 |
uint8_t sync_index, /**< Sync manager index. */ |
814 | 144 |
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
|
145 |
) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
unsigned int i; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
148 |
ec_fmmu_config_t *fmmu; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
149 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
150 |
// FMMU configuration already prepared? |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
151 |
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
|
152 |
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
|
153 |
if (fmmu->domain == domain && fmmu->sync_index == sync_index) |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
154 |
return fmmu->logical_start_address; |
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 |
if (sc->used_fmmus == EC_MAX_FMMUS) { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
158 |
EC_ERR("FMMU limit reached for slave configuration %u:%u!\n", |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
159 |
sc->alias, sc->position); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
160 |
return -EOVERFLOW; |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
161 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
162 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
163 |
fmmu = &sc->fmmu_configs[sc->used_fmmus++]; |
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
|
164 |
|
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
|
165 |
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
|
166 |
ec_fmmu_config_init(fmmu, sc, domain, sync_index, dir); |
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
|
167 |
up(&sc->master->master_sem); |
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
|
168 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
169 |
return fmmu->logical_start_address; |
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 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
172 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
173 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
174 |
/** 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
|
175 |
* |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
176 |
* \retval 0 Success. |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
177 |
* \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
|
178 |
*/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
179 |
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
|
180 |
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
|
181 |
) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
182 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
183 |
ec_slave_t *slave; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
184 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
185 |
if (sc->slave) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
186 |
return 0; // already attached |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
187 |
|
927
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
188 |
if (!(slave = ec_master_find_slave( |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
189 |
sc->master, sc->alias, sc->position))) { |
1025
ae175095f09a
Output attachment failure messages only when debugging.
Florian Pose <fp@igh-essen.com>
parents:
1022
diff
changeset
|
190 |
if (sc->master->debug_level) |
ae175095f09a
Output attachment failure messages only when debugging.
Florian Pose <fp@igh-essen.com>
parents:
1022
diff
changeset
|
191 |
EC_DBG("Failed to find slave for configuration %u:%u.\n", |
ae175095f09a
Output attachment failure messages only when debugging.
Florian Pose <fp@igh-essen.com>
parents:
1022
diff
changeset
|
192 |
sc->alias, sc->position); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
193 |
return -ENOENT; |
927
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
194 |
} |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
195 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
196 |
if (slave->config) { |
1025
ae175095f09a
Output attachment failure messages only when debugging.
Florian Pose <fp@igh-essen.com>
parents:
1022
diff
changeset
|
197 |
if (sc->master->debug_level) |
ae175095f09a
Output attachment failure messages only when debugging.
Florian Pose <fp@igh-essen.com>
parents:
1022
diff
changeset
|
198 |
EC_DBG("Failed to attach slave configuration %u:%u. Slave %u" |
ae175095f09a
Output attachment failure messages only when debugging.
Florian Pose <fp@igh-essen.com>
parents:
1022
diff
changeset
|
199 |
" already has a configuration!\n", sc->alias, |
ae175095f09a
Output attachment failure messages only when debugging.
Florian Pose <fp@igh-essen.com>
parents:
1022
diff
changeset
|
200 |
sc->position, slave->ring_position); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
201 |
return -EEXIST; |
1025
ae175095f09a
Output attachment failure messages only when debugging.
Florian Pose <fp@igh-essen.com>
parents:
1022
diff
changeset
|
202 |
} |
1145
133cf4631fcc
Force reconfiguration after attachment.
Florian Pose <fp@igh-essen.com>
parents:
1115
diff
changeset
|
203 |
|
1025
ae175095f09a
Output attachment failure messages only when debugging.
Florian Pose <fp@igh-essen.com>
parents:
1022
diff
changeset
|
204 |
if (slave->sii.vendor_id != sc->vendor_id |
ae175095f09a
Output attachment failure messages only when debugging.
Florian Pose <fp@igh-essen.com>
parents:
1022
diff
changeset
|
205 |
|| slave->sii.product_code != sc->product_code) { |
ae175095f09a
Output attachment failure messages only when debugging.
Florian Pose <fp@igh-essen.com>
parents:
1022
diff
changeset
|
206 |
if (sc->master->debug_level) |
ae175095f09a
Output attachment failure messages only when debugging.
Florian Pose <fp@igh-essen.com>
parents:
1022
diff
changeset
|
207 |
EC_DBG("Slave %u has an invalid type (0x%08X/0x%08X) for" |
ae175095f09a
Output attachment failure messages only when debugging.
Florian Pose <fp@igh-essen.com>
parents:
1022
diff
changeset
|
208 |
" configuration %u:%u (0x%08X/0x%08X).\n", |
ae175095f09a
Output attachment failure messages only when debugging.
Florian Pose <fp@igh-essen.com>
parents:
1022
diff
changeset
|
209 |
slave->ring_position, slave->sii.vendor_id, |
ae175095f09a
Output attachment failure messages only when debugging.
Florian Pose <fp@igh-essen.com>
parents:
1022
diff
changeset
|
210 |
slave->sii.product_code, sc->alias, sc->position, |
ae175095f09a
Output attachment failure messages only when debugging.
Florian Pose <fp@igh-essen.com>
parents:
1022
diff
changeset
|
211 |
sc->vendor_id, sc->product_code); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
212 |
return -EINVAL; |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
213 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
214 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
215 |
// attach slave |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
216 |
slave->config = sc; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
217 |
sc->slave = slave; |
1145
133cf4631fcc
Force reconfiguration after attachment.
Florian Pose <fp@igh-essen.com>
parents:
1115
diff
changeset
|
218 |
|
1025
ae175095f09a
Output attachment failure messages only when debugging.
Florian Pose <fp@igh-essen.com>
parents:
1022
diff
changeset
|
219 |
ec_slave_request_state(slave, EC_SLAVE_STATE_OP); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
220 |
|
929 | 221 |
if (sc->master->debug_level) |
222 |
EC_DBG("Attached slave %u to config %u:%u.\n", |
|
223 |
slave->ring_position, sc->alias, sc->position); |
|
224 |
||
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
225 |
return 0; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
226 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
227 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
228 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
229 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
230 |
/** 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
|
231 |
*/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
232 |
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
|
233 |
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
|
234 |
) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
235 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
236 |
if (sc->slave) { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
237 |
sc->slave->config = NULL; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
238 |
sc->slave = NULL; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
239 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
240 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
241 |
|
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 |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
244 |
/** Loads the default Pdo assignment from the slave object. |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
245 |
*/ |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
246 |
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
|
247 |
{ |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
248 |
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
|
249 |
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
|
250 |
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
|
251 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
252 |
if (!sc->slave) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
253 |
return; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
254 |
|
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
255 |
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
|
256 |
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
|
257 |
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
|
258 |
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
|
259 |
if (sync_config->dir == EC_DIR_INVALID) |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
260 |
EC_WARN("SM%u of slave %u has an invalid direction field!\n", |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
261 |
sync_index, sc->slave->ring_position); |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
262 |
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
|
263 |
} |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
264 |
} |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
265 |
} |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
266 |
|
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
267 |
/*****************************************************************************/ |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
268 |
|
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
269 |
/** Loads the default mapping for a Pdo from the slave object. |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
270 |
*/ |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
271 |
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
|
272 |
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
|
273 |
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
|
274 |
) |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
275 |
{ |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
276 |
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
|
277 |
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
|
278 |
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
|
279 |
|
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
280 |
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
|
281 |
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
|
282 |
|
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
283 |
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
|
284 |
EC_DBG("Loading default mapping for Pdo 0x%04X in config %u:%u.\n", |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
285 |
pdo->index, sc->alias, sc->position); |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
286 |
|
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
287 |
// find Pdo in any sync manager (it could be reassigned later) |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
288 |
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
|
289 |
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
|
290 |
|
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
291 |
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
|
292 |
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
|
293 |
continue; |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
294 |
|
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
295 |
if (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
|
296 |
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
|
297 |
EC_DBG("Found Pdo name \"%s\".\n", 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
|
298 |
|
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
299 |
// take Pdo name from assigned one |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
300 |
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
|
301 |
} |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
302 |
|
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
303 |
// copy entries (= default Pdo mapping) |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
304 |
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
|
305 |
return; |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
306 |
|
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
307 |
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
|
308 |
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
|
309 |
list_for_each_entry(entry, &pdo->entries, list) { |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
310 |
EC_DBG("Entry 0x%04X:%02X.\n", |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
311 |
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
|
312 |
} |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
313 |
} |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
314 |
|
842
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
315 |
return; |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
316 |
} |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
317 |
} |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
318 |
|
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
319 |
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
|
320 |
EC_DBG("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
|
321 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
322 |
|
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
323 |
/*****************************************************************************/ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
324 |
|
1092 | 325 |
/** Get the number of Sdo configurations. |
326 |
* |
|
327 |
* \return Number of Sdo configurations. |
|
328 |
*/ |
|
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
329 |
unsigned int ec_slave_config_sdo_count( |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
330 |
const ec_slave_config_t *sc /**< Slave configuration. */ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
331 |
) |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
332 |
{ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
333 |
const ec_sdo_request_t *req; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
334 |
unsigned int count = 0; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
335 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
336 |
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
|
337 |
count++; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
338 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
339 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
340 |
return count; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
341 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
342 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
343 |
/*****************************************************************************/ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
344 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
345 |
/** Finds an Sdo configuration via its position in the list. |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
346 |
* |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
347 |
* Const version. |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
348 |
*/ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
349 |
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
|
350 |
const ec_slave_config_t *sc, /**< Slave configuration. */ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
351 |
unsigned int pos /**< Position in the list. */ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
352 |
) |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
353 |
{ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
354 |
const ec_sdo_request_t *req; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
355 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
356 |
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
|
357 |
if (pos--) |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
358 |
continue; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
359 |
return req; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
360 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
361 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
362 |
return NULL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
363 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
941
diff
changeset
|
364 |
|
1263
f44720defbc5
Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents:
1215
diff
changeset
|
365 |
/*****************************************************************************/ |
f44720defbc5
Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents:
1215
diff
changeset
|
366 |
|
f44720defbc5
Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents:
1215
diff
changeset
|
367 |
/** Finds a VoE handler via its position in the list. |
f44720defbc5
Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents:
1215
diff
changeset
|
368 |
*/ |
f44720defbc5
Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents:
1215
diff
changeset
|
369 |
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
|
370 |
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
|
371 |
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
|
372 |
) |
f44720defbc5
Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents:
1215
diff
changeset
|
373 |
{ |
f44720defbc5
Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents:
1215
diff
changeset
|
374 |
ec_voe_handler_t *voe; |
f44720defbc5
Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents:
1215
diff
changeset
|
375 |
|
f44720defbc5
Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents:
1215
diff
changeset
|
376 |
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
|
377 |
if (pos--) |
f44720defbc5
Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents:
1215
diff
changeset
|
378 |
continue; |
f44720defbc5
Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents:
1215
diff
changeset
|
379 |
return voe; |
f44720defbc5
Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents:
1215
diff
changeset
|
380 |
} |
f44720defbc5
Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents:
1215
diff
changeset
|
381 |
|
f44720defbc5
Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents:
1215
diff
changeset
|
382 |
return NULL; |
f44720defbc5
Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents:
1215
diff
changeset
|
383 |
} |
f44720defbc5
Added ec_slave_config_find_voe_handler().
Florian Pose <fp@igh-essen.com>
parents:
1215
diff
changeset
|
384 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
385 |
/****************************************************************************** |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
386 |
* Realtime interface |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
387 |
*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
388 |
|
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
389 |
int ecrt_slave_config_sync_manager(ec_slave_config_t *sc, 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
|
390 |
ec_direction_t dir) |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
391 |
{ |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
392 |
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
|
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 |
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
|
395 |
EC_DBG("ecrt_slave_config_sync_manager(sc = 0x%x, sync_index = %u, " |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
396 |
"dir = %u)\n", (u32) sc, sync_index, dir); |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
397 |
|
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
398 |
if (sync_index >= EC_MAX_SYNC_MANAGERS) { |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
399 |
EC_ERR("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
|
400 |
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
|
401 |
} |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
402 |
|
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
403 |
if (dir != EC_DIR_OUTPUT && dir != EC_DIR_INPUT) { |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
404 |
EC_ERR("Invalid direction %u!\n", (u32) dir); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
405 |
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
|
406 |
} |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
407 |
|
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
408 |
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
|
409 |
sync_config->dir = dir; |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
410 |
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
|
411 |
} |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
412 |
|
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
413 |
/*****************************************************************************/ |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
414 |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
415 |
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
|
416 |
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
|
417 |
{ |
842
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
418 |
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
|
419 |
|
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
420 |
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
|
421 |
EC_DBG("ecrt_slave_config_pdo_assign_add(sc = 0x%x, sync_index = %u, " |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
422 |
"pdo_index = 0x%04X)\n", (u32) sc, sync_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
|
423 |
|
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
424 |
if (sync_index >= EC_MAX_SYNC_MANAGERS) { |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
425 |
EC_ERR("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
|
426 |
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
|
427 |
} |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
428 |
|
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
|
429 |
down(&sc->master->master_sem); |
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
|
430 |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
431 |
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
|
432 |
if (IS_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
|
433 |
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
|
434 |
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
|
435 |
} |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
436 |
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
|
437 |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
438 |
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
|
439 |
|
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
|
440 |
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
|
441 |
return 0; |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
442 |
} |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
443 |
|
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
444 |
/*****************************************************************************/ |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
445 |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
446 |
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
|
447 |
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
|
448 |
{ |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
449 |
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
|
450 |
EC_DBG("ecrt_slave_config_pdo_assign_clear(sc = 0x%x, " |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
451 |
"sync_index = %u)\n", (u32) sc, 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
|
452 |
|
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
453 |
if (sync_index >= EC_MAX_SYNC_MANAGERS) { |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
454 |
EC_ERR("Invalid sync manager index %u!\n", 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
|
455 |
return; |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
456 |
} |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
457 |
|
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
|
458 |
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
|
459 |
ec_pdo_list_clear_pdos(&sc->sync_configs[sync_index].pdos); |
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
|
460 |
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
|
461 |
} |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
462 |
|
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
463 |
/*****************************************************************************/ |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
464 |
|
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
465 |
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
|
466 |
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
|
467 |
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
|
468 |
{ |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
469 |
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
|
470 |
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
|
471 |
ec_pdo_entry_t *entry; |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
472 |
int retval = 0; |
842
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
473 |
|
843
b6bddb663755
Added some debugging and fixed a bug, when Pdo was not found.
Florian Pose <fp@igh-essen.com>
parents:
842
diff
changeset
|
474 |
if (sc->master->debug_level) |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
475 |
EC_DBG("ecrt_slave_config_pdo_mapping_add(sc = 0x%x, " |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
476 |
"pdo_index = 0x%04X, entry_index = 0x%04X, " |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
477 |
"entry_subindex = 0x%02X, entry_bit_length = %u)\n", |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
478 |
(u32) sc, pdo_index, 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
|
479 |
entry_bit_length); |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
480 |
|
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
481 |
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
|
482 |
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
|
483 |
&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
|
484 |
break; |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
485 |
|
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
|
486 |
if (pdo) { |
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
|
487 |
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
|
488 |
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
|
489 |
entry_bit_length); |
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
|
490 |
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
|
491 |
if (IS_ERR(entry)) |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
492 |
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
|
493 |
} else { |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
494 |
EC_ERR("Pdo 0x%04X is not assigned in config %u:%u.\n", |
843
b6bddb663755
Added some debugging and fixed a bug, when Pdo was not found.
Florian Pose <fp@igh-essen.com>
parents:
842
diff
changeset
|
495 |
pdo_index, sc->alias, sc->position); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
496 |
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
|
497 |
} |
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
|
498 |
|
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
|
499 |
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
|
500 |
} |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
501 |
|
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
502 |
/*****************************************************************************/ |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
503 |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
504 |
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
|
505 |
uint16_t pdo_index) |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
506 |
{ |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
507 |
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
|
508 |
ec_pdo_t *pdo = NULL; |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
509 |
|
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
510 |
if (sc->master->debug_level) |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
511 |
EC_DBG("ecrt_slave_config_pdo_mapping_clear(sc = 0x%x, " |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
512 |
"pdo_index = 0x%04X)\n", (u32) sc, 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
|
513 |
|
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
514 |
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
|
515 |
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
|
516 |
&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
|
517 |
break; |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
518 |
|
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
|
519 |
if (pdo) { |
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
|
520 |
down(&sc->master->master_sem); |
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
|
521 |
ec_pdo_clear_entries(pdo); |
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
|
522 |
up(&sc->master->master_sem); |
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
|
523 |
} else { |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
524 |
EC_WARN("Pdo 0x%04X is not assigned in config %u:%u.\n", |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
525 |
pdo_index, sc->alias, sc->position); |
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
|
526 |
} |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
527 |
} |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
528 |
|
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
529 |
/*****************************************************************************/ |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
530 |
|
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
531 |
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
|
532 |
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
|
533 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
534 |
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
|
535 |
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
|
536 |
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
|
537 |
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
|
538 |
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
|
539 |
|
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
540 |
if (sc->master->debug_level) |
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
541 |
EC_DBG("ecrt_slave_config_pdos(sc = 0x%x, n_syncs = %u, " |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
542 |
"syncs = 0x%x)\n", (u32) sc, n_syncs, (u32) syncs); |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
543 |
|
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
544 |
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
|
545 |
return 0; |
4c16fe64b403
Return out of ecrt_slave_config_pdos() when pdo_infos == NULL
Richard Hacker <ha@igh-essen.com>
parents:
1025
diff
changeset
|
546 |
|
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
547 |
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
|
548 |
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
|
549 |
|
1097 | 550 |
if (sync_info->index == (uint8_t) EC_END) |
878 | 551 |
break; |
552 |
||
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
553 |
if (sync_info->index >= EC_MAX_SYNC_MANAGERS) { |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
554 |
EC_ERR("Invalid sync manager index %u!\n", sync_info->index); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
555 |
return -ENOENT; |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
556 |
} |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
557 |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
558 |
ret = ecrt_slave_config_sync_manager( |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
559 |
sc, sync_info->index, sync_info->dir); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
560 |
if (ret) |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
561 |
return ret; |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
562 |
|
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
563 |
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
|
564 |
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
|
565 |
|
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
566 |
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
|
567 |
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
|
568 |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
569 |
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
|
570 |
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
|
571 |
if (ret) |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
572 |
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
|
573 |
|
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
574 |
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
|
575 |
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
|
576 |
|
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
577 |
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
|
578 |
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
|
579 |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
580 |
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
|
581 |
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
|
582 |
entry_info->subindex, |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
583 |
entry_info->bit_length); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
584 |
if (ret) |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
585 |
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
|
586 |
} |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
587 |
} |
842
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
588 |
} |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
589 |
} |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
590 |
} |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
591 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
592 |
return 0; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
593 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
594 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
595 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
596 |
|
807
f8bca95ab75d
Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents:
797
diff
changeset
|
597 |
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
|
598 |
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
|
599 |
uint16_t index, |
a6b51990e7e6
Changed Pdo entry registration function - return byte and bit positions
Richard Hacker <ha@igh-essen.com>
parents:
916
diff
changeset
|
600 |
uint8_t subindex, |
a6b51990e7e6
Changed Pdo entry registration function - return byte and bit positions
Richard Hacker <ha@igh-essen.com>
parents:
916
diff
changeset
|
601 |
ec_domain_t *domain, |
925
939f3e9bba1e
Some improvements concerning bit_position.
Florian Pose <fp@igh-essen.com>
parents:
924
diff
changeset
|
602 |
unsigned int *bit_position |
916
db73994fbdac
Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents:
893
diff
changeset
|
603 |
) |
db73994fbdac
Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents:
893
diff
changeset
|
604 |
{ |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
605 |
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
|
606 |
const ec_sync_config_t *sync_config; |
925
939f3e9bba1e
Some improvements concerning bit_position.
Florian Pose <fp@igh-essen.com>
parents:
924
diff
changeset
|
607 |
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
|
608 |
ec_pdo_t *pdo; |
f8bca95ab75d
Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents:
797
diff
changeset
|
609 |
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
|
610 |
int sync_offset; |
807
f8bca95ab75d
Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents:
797
diff
changeset
|
611 |
|
941
41a993738383
Added debugging for ecrt_slave_config_reg_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
929
diff
changeset
|
612 |
if (sc->master->debug_level) |
41a993738383
Added debugging for ecrt_slave_config_reg_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
929
diff
changeset
|
613 |
EC_DBG("ecrt_slave_config_reg_pdo_entry(sc = 0x%x, index = 0x%04X, " |
41a993738383
Added debugging for ecrt_slave_config_reg_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
929
diff
changeset
|
614 |
"subindex = 0x%02X, domain = 0x%x, bit_position = 0x%x)\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
|
615 |
(u32) sc, index, subindex, (u32) domain, (u32) 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
|
616 |
|
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
617 |
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
|
618 |
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
|
619 |
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
|
620 |
|
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
621 |
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
|
622 |
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
|
623 |
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
|
624 |
bit_offset += entry->bit_length; |
f8bca95ab75d
Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents:
797
diff
changeset
|
625 |
} 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
|
626 |
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
|
627 |
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
|
628 |
*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
|
629 |
} else if (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
|
630 |
EC_ERR("Pdo entry 0x%04X:%02X does not byte-align " |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
631 |
"in config %u:%u.\n", index, subindex, |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
632 |
sc->alias, sc->position); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
633 |
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
|
634 |
} |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
635 |
|
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
|
636 |
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
|
637 |
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
|
638 |
if (sync_offset < 0) |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
639 |
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
|
640 |
|
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 |
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
|
642 |
} |
f8bca95ab75d
Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents:
797
diff
changeset
|
643 |
} |
f8bca95ab75d
Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents:
797
diff
changeset
|
644 |
} |
f8bca95ab75d
Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents:
797
diff
changeset
|
645 |
} |
f8bca95ab75d
Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents:
797
diff
changeset
|
646 |
|
926
6bb33c6ec770
Output subindices with %02X.
Florian Pose <fp@igh-essen.com>
parents:
925
diff
changeset
|
647 |
EC_ERR("Pdo entry 0x%04X:%02X is not mapped in slave config %u:%u.\n", |
807
f8bca95ab75d
Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents:
797
diff
changeset
|
648 |
index, subindex, sc->alias, sc->position); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
649 |
return -ENOENT; |
924
d8d9a1056afa
Fixed missing right brace
Richard Hacker <ha@igh-essen.com>
parents:
923
diff
changeset
|
650 |
} |
923
a6b51990e7e6
Changed Pdo entry registration function - return byte and bit positions
Richard Hacker <ha@igh-essen.com>
parents:
916
diff
changeset
|
651 |
|
807
f8bca95ab75d
Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents:
797
diff
changeset
|
652 |
|
f8bca95ab75d
Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents:
797
diff
changeset
|
653 |
/*****************************************************************************/ |
f8bca95ab75d
Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents:
797
diff
changeset
|
654 |
|
893
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
655 |
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
|
656 |
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
|
657 |
{ |
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
658 |
ec_slave_t *slave = sc->slave; |
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
659 |
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
|
660 |
int ret; |
893
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
661 |
|
1115
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
662 |
if (sc->master->debug_level) |
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
663 |
EC_DBG("ecrt_slave_config_sdo(sc = 0x%x, index = 0x%04X, " |
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
664 |
"subindex = 0x%02X, data = 0x%x, size = %u)\n", (u32) sc, |
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
665 |
index, subindex, (u32) data, size); |
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
666 |
|
893
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
667 |
if (slave && !(slave->sii.mailbox_protocols & EC_MBOX_COE)) { |
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
668 |
EC_ERR("Slave %u does not support CoE!\n", slave->ring_position); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
669 |
return -EPROTONOSUPPORT; // protocol not supported |
893
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
670 |
} |
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
671 |
|
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
672 |
if (!(req = (ec_sdo_request_t *) |
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
673 |
kmalloc(sizeof(ec_sdo_request_t), GFP_KERNEL))) { |
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
674 |
EC_ERR("Failed to allocate memory for Sdo configuration!\n"); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
675 |
return -ENOMEM; |
893
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
676 |
} |
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
677 |
|
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
678 |
ec_sdo_request_init(req); |
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
679 |
ec_sdo_request_address(req, index, subindex); |
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
680 |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
681 |
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
|
682 |
if (ret < 0) { |
893
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
683 |
ec_sdo_request_clear(req); |
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
684 |
kfree(req); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
685 |
return ret; |
893
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
686 |
} |
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
687 |
|
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
|
688 |
down(&sc->master->master_sem); |
893
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
689 |
list_add_tail(&req->list, &sc->sdo_configs); |
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
|
690 |
up(&sc->master->master_sem); |
893
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
691 |
return 0; |
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
692 |
} |
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
693 |
|
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
694 |
/*****************************************************************************/ |
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
695 |
|
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
696 |
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
|
697 |
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
|
698 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
699 |
uint8_t data[1]; |
1115
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
700 |
|
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
701 |
if (sc->master->debug_level) |
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
702 |
EC_DBG("ecrt_slave_config_sdo8(sc = 0x%x, index = 0x%04X, " |
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
703 |
"subindex = 0x%02X, value = %u)\n", (u32) sc, |
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
704 |
index, subindex, (u32) value); |
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
705 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
706 |
EC_WRITE_U8(data, value); |
893
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
707 |
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
|
708 |
} |
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
709 |
|
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
710 |
/*****************************************************************************/ |
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
711 |
|
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
712 |
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
|
713 |
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
|
714 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
715 |
uint8_t data[2]; |
1115
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
716 |
|
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
717 |
if (sc->master->debug_level) |
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
718 |
EC_DBG("ecrt_slave_config_sdo16(sc = 0x%x, index = 0x%04X, " |
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
719 |
"subindex = 0x%02X, value = %u)\n", (u32) sc, |
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
720 |
index, subindex, value); |
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
721 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
722 |
EC_WRITE_U16(data, value); |
893
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
723 |
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
|
724 |
} |
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
725 |
|
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
726 |
/*****************************************************************************/ |
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
727 |
|
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
728 |
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
|
729 |
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
|
730 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
731 |
uint8_t data[4]; |
1115
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
732 |
|
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
733 |
if (sc->master->debug_level) |
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
734 |
EC_DBG("ecrt_slave_config_sdo32(sc = 0x%x, index = 0x%04X, " |
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
735 |
"subindex = 0x%02X, value = %u)\n", (u32) sc, |
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
736 |
index, subindex, value); |
b7b965ab94cd
Sdo configuration debugging.
Florian Pose <fp@igh-essen.com>
parents:
1097
diff
changeset
|
737 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
738 |
EC_WRITE_U32(data, value); |
893
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
739 |
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
|
740 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
741 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
742 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
743 |
|
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
744 |
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
|
745 |
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
|
746 |
{ |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
747 |
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
|
748 |
int ret; |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
749 |
|
1181
9e5954a2a46e
Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents:
1178
diff
changeset
|
750 |
if (sc->master->debug_level) |
9e5954a2a46e
Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents:
1178
diff
changeset
|
751 |
EC_DBG("ecrt_slave_config_create_sdo_request(sc = 0x%x, " |
9e5954a2a46e
Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents:
1178
diff
changeset
|
752 |
"index = 0x%04X, subindex = 0x%02X, size = %u)\n", (u32) sc, |
9e5954a2a46e
Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents:
1178
diff
changeset
|
753 |
index, subindex, size); |
9e5954a2a46e
Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents:
1178
diff
changeset
|
754 |
|
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
755 |
if (!(req = (ec_sdo_request_t *) |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
756 |
kmalloc(sizeof(ec_sdo_request_t), GFP_KERNEL))) { |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
757 |
EC_ERR("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
|
758 |
return ERR_PTR(-ENOMEM); |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
759 |
} |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
760 |
|
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
761 |
ec_sdo_request_init(req); |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
762 |
ec_sdo_request_address(req, index, subindex); |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
763 |
|
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
764 |
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
|
765 |
if (ret < 0) { |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
766 |
ec_sdo_request_clear(req); |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
767 |
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
|
768 |
return ERR_PTR(ret); |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
769 |
} |
859
233e32f428e1
Replaced ec_fsm_coe_\(upload\|download\)() with ec_fsm_coe_transfer();
Florian Pose <fp@igh-essen.com>
parents:
858
diff
changeset
|
770 |
|
233e32f428e1
Replaced ec_fsm_coe_\(upload\|download\)() with ec_fsm_coe_transfer();
Florian Pose <fp@igh-essen.com>
parents:
858
diff
changeset
|
771 |
// 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
|
772 |
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
|
773 |
req->data_size = size; |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
774 |
|
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
|
775 |
down(&sc->master->master_sem); |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
776 |
list_add_tail(&req->list, &sc->sdo_requests); |
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
|
777 |
up(&sc->master->master_sem); |
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
|
778 |
|
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
779 |
return req; |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
780 |
} |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
781 |
|
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
782 |
/*****************************************************************************/ |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
783 |
|
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
784 |
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
|
785 |
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
|
786 |
{ |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
787 |
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
|
788 |
subindex, size); |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
789 |
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
|
790 |
} |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
791 |
|
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
792 |
/*****************************************************************************/ |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
793 |
|
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
794 |
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
|
795 |
ec_slave_config_t *sc, size_t size) |
1209 | 796 |
{ |
797 |
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
|
798 |
int ret; |
1209 | 799 |
|
800 |
if (sc->master->debug_level) |
|
801 |
EC_DBG("ecrt_slave_config_create_voe_handler(sc = 0x%x, size = %u)\n", |
|
802 |
(u32) sc, size); |
|
803 |
||
804 |
if (!(voe = (ec_voe_handler_t *) |
|
805 |
kmalloc(sizeof(ec_voe_handler_t), GFP_KERNEL))) { |
|
806 |
EC_ERR("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
|
807 |
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
|
808 |
} |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
809 |
|
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
810 |
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
|
811 |
if (ret < 0) { |
1209 | 812 |
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
|
813 |
return ERR_PTR(ret); |
1209 | 814 |
} |
815 |
||
816 |
down(&sc->master->master_sem); |
|
817 |
list_add_tail(&voe->list, &sc->voe_handlers); |
|
818 |
up(&sc->master->master_sem); |
|
819 |
||
820 |
return voe; |
|
821 |
} |
|
822 |
||
823 |
/*****************************************************************************/ |
|
824 |
||
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
825 |
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
|
826 |
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
|
827 |
{ |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
828 |
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
|
829 |
size); |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
830 |
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
|
831 |
} |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
832 |
|
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
833 |
/*****************************************************************************/ |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
834 |
|
1022
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
835 |
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
|
836 |
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
|
837 |
{ |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
838 |
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
|
839 |
if (state->online) { |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
840 |
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
|
841 |
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
|
842 |
&& !sc->slave->force_config; |
1022
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
843 |
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
|
844 |
} else { |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
845 |
state->operational = 0; |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
846 |
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
|
847 |
} |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
848 |
} |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
849 |
|
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
850 |
/*****************************************************************************/ |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
851 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
852 |
/** \cond */ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
853 |
|
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1054
diff
changeset
|
854 |
EXPORT_SYMBOL(ecrt_slave_config_sync_manager); |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
855 |
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
|
856 |
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
|
857 |
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
|
858 |
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
|
859 |
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
|
860 |
EXPORT_SYMBOL(ecrt_slave_config_reg_pdo_entry); |
893
d921fff3d6e2
Exported ecrt_slave_config_sdo(); added documentation.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
861 |
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
|
862 |
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
|
863 |
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
|
864 |
EXPORT_SYMBOL(ecrt_slave_config_sdo32); |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
865 |
EXPORT_SYMBOL(ecrt_slave_config_create_sdo_request); |
1215 | 866 |
EXPORT_SYMBOL(ecrt_slave_config_create_voe_handler); |
1022
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
867 |
EXPORT_SYMBOL(ecrt_slave_config_state); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
868 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
869 |
/** \endcond */ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
870 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
871 |
/*****************************************************************************/ |