author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Mon, 10 Sep 2018 22:40:27 +0200 | |
branch | stable-1.5 |
changeset 2705 | c6e3c6d66af0 |
parent 2522 | ec403cf308eb |
permissions | -rw-r--r-- |
628
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
1326
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
5 |
* Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH |
628
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
* |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
* |
1326
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it and/or |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
10 |
* modify it under the terms of the GNU General Public License version 2, as |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
11 |
* published by the Free Software Foundation. |
628
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
* |
1326
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
13 |
* The IgH EtherCAT Master is distributed in the hope that it will be useful, |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
16 |
* Public License for more details. |
628
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
* |
1326
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License along |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
19 |
* with the IgH EtherCAT Master; if not, write to the Free Software |
628
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
22 |
* --- |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
23 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
24 |
* The license mentioned above concerns the source code only. Using the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
25 |
* EtherCAT technology and brand is only permitted in compliance with the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
628
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
* |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
*****************************************************************************/ |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
30 |
/** \file |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
31 |
* EtherCAT sync manager methods. |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
32 |
*/ |
628
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
|
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
/*****************************************************************************/ |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
|
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
#include "globals.h" |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
#include "slave.h" |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
#include "master.h" |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
39 |
#include "pdo.h" |
628
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
#include "sync.h" |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
|
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
/*****************************************************************************/ |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
44 |
/** Constructor. |
628
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
*/ |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
void ec_sync_init( |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
47 |
ec_sync_t *sync, /**< EtherCAT sync manager. */ |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
943
diff
changeset
|
48 |
ec_slave_t *slave /**< EtherCAT slave. */ |
628
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
) |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
{ |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
sync->slave = slave; |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
943
diff
changeset
|
52 |
sync->physical_start_address = 0x0000; |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
943
diff
changeset
|
53 |
sync->default_length = 0x0000; |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
943
diff
changeset
|
54 |
sync->control_register = 0x00; |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
943
diff
changeset
|
55 |
sync->enable = 0x00; |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
56 |
ec_pdo_list_init(&sync->pdos); |
628
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
} |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
58 |
|
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
59 |
/*****************************************************************************/ |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
60 |
|
873
ec01ba291896
Fixed bug in copying sync managers. Now making a deep copy.
Florian Pose <fp@igh-essen.com>
parents:
872
diff
changeset
|
61 |
/** Copy constructor. |
ec01ba291896
Fixed bug in copying sync managers. Now making a deep copy.
Florian Pose <fp@igh-essen.com>
parents:
872
diff
changeset
|
62 |
*/ |
ec01ba291896
Fixed bug in copying sync managers. Now making a deep copy.
Florian Pose <fp@igh-essen.com>
parents:
872
diff
changeset
|
63 |
void ec_sync_init_copy( |
ec01ba291896
Fixed bug in copying sync managers. Now making a deep copy.
Florian Pose <fp@igh-essen.com>
parents:
872
diff
changeset
|
64 |
ec_sync_t *sync, /**< EtherCAT sync manager. */ |
ec01ba291896
Fixed bug in copying sync managers. Now making a deep copy.
Florian Pose <fp@igh-essen.com>
parents:
872
diff
changeset
|
65 |
const ec_sync_t *other /**< Sync manager to copy from. */ |
ec01ba291896
Fixed bug in copying sync managers. Now making a deep copy.
Florian Pose <fp@igh-essen.com>
parents:
872
diff
changeset
|
66 |
) |
ec01ba291896
Fixed bug in copying sync managers. Now making a deep copy.
Florian Pose <fp@igh-essen.com>
parents:
872
diff
changeset
|
67 |
{ |
ec01ba291896
Fixed bug in copying sync managers. Now making a deep copy.
Florian Pose <fp@igh-essen.com>
parents:
872
diff
changeset
|
68 |
sync->slave = other->slave; |
ec01ba291896
Fixed bug in copying sync managers. Now making a deep copy.
Florian Pose <fp@igh-essen.com>
parents:
872
diff
changeset
|
69 |
sync->physical_start_address = other->physical_start_address; |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
943
diff
changeset
|
70 |
sync->default_length = other->default_length; |
873
ec01ba291896
Fixed bug in copying sync managers. Now making a deep copy.
Florian Pose <fp@igh-essen.com>
parents:
872
diff
changeset
|
71 |
sync->control_register = other->control_register; |
ec01ba291896
Fixed bug in copying sync managers. Now making a deep copy.
Florian Pose <fp@igh-essen.com>
parents:
872
diff
changeset
|
72 |
sync->enable = other->enable; |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
73 |
ec_pdo_list_init(&sync->pdos); |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
74 |
ec_pdo_list_copy(&sync->pdos, &other->pdos); |
873
ec01ba291896
Fixed bug in copying sync managers. Now making a deep copy.
Florian Pose <fp@igh-essen.com>
parents:
872
diff
changeset
|
75 |
} |
ec01ba291896
Fixed bug in copying sync managers. Now making a deep copy.
Florian Pose <fp@igh-essen.com>
parents:
872
diff
changeset
|
76 |
|
ec01ba291896
Fixed bug in copying sync managers. Now making a deep copy.
Florian Pose <fp@igh-essen.com>
parents:
872
diff
changeset
|
77 |
/*****************************************************************************/ |
ec01ba291896
Fixed bug in copying sync managers. Now making a deep copy.
Florian Pose <fp@igh-essen.com>
parents:
872
diff
changeset
|
78 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
79 |
/** Destructor. |
628
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
80 |
*/ |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
void ec_sync_clear( |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
82 |
ec_sync_t *sync /**< EtherCAT sync manager. */ |
628
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
83 |
) |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
{ |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
85 |
ec_pdo_list_clear(&sync->pdos); |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
86 |
} |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
87 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
88 |
/*****************************************************************************/ |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
89 |
|
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
943
diff
changeset
|
90 |
/** Initializes a sync manager configuration page. |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
91 |
* |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
92 |
* The referenced memory (\a data) must be at least \a EC_SYNC_SIZE bytes. |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
93 |
*/ |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
943
diff
changeset
|
94 |
void ec_sync_page( |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
95 |
const ec_sync_t *sync, /**< Sync manager. */ |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
943
diff
changeset
|
96 |
uint8_t sync_index, /**< Index of the sync manager. */ |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
97 |
uint16_t data_size, /**< Data size. */ |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
98 |
const ec_sync_config_t *sync_config, /**< Configuration. */ |
2123
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
99 |
uint8_t pdo_xfer, /**< Non-zero, if PDOs will be transferred via this |
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
100 |
sync manager. */ |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
101 |
uint8_t *data /**> Configuration memory. */ |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
102 |
) |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
103 |
{ |
2123
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
104 |
// enable only if (SII enable is set or PDO xfer) |
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
105 |
// and size is > 0 and SM is not virtual |
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
106 |
uint16_t enable = ((sync->enable & 0x01) || pdo_xfer) |
1801
31af610f1639
Support of virtual sync managers
Dominik Staubli <ch1010252@ch10pc423>
parents:
1509
diff
changeset
|
107 |
&& data_size |
31af610f1639
Support of virtual sync managers
Dominik Staubli <ch1010252@ch10pc423>
parents:
1509
diff
changeset
|
108 |
&& ((sync->enable & 0x04) == 0); |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
943
diff
changeset
|
109 |
uint8_t control = sync->control_register; |
943
1d9e2663e087
Enable sync managers only if SII enable is set and size is greater zero.
Florian Pose <fp@igh-essen.com>
parents:
912
diff
changeset
|
110 |
|
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
111 |
if (sync_config) { |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
112 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
113 |
switch (sync_config->dir) { |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
114 |
case EC_DIR_OUTPUT: |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
115 |
case EC_DIR_INPUT: |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
116 |
EC_WRITE_BIT(&control, 2, |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
117 |
sync_config->dir == EC_DIR_OUTPUT ? 1 : 0); |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
118 |
EC_WRITE_BIT(&control, 3, 0); |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
119 |
break; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
120 |
default: |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
121 |
break; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
122 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
123 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
124 |
switch (sync_config->watchdog_mode) { |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
125 |
case EC_WD_ENABLE: |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
126 |
case EC_WD_DISABLE: |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
127 |
EC_WRITE_BIT(&control, 6, |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
128 |
sync_config->watchdog_mode == EC_WD_ENABLE); |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
129 |
break; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
130 |
default: |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
131 |
break; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
132 |
} |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
943
diff
changeset
|
133 |
} |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
943
diff
changeset
|
134 |
|
1921 | 135 |
EC_SLAVE_DBG(sync->slave, 1, "SM%u: Addr 0x%04X, Size %3u," |
136 |
" Ctrl 0x%02X, En %u\n", |
|
137 |
sync_index, sync->physical_start_address, |
|
138 |
data_size, control, enable); |
|
628
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
139 |
|
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
140 |
EC_WRITE_U16(data, sync->physical_start_address); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
141 |
EC_WRITE_U16(data + 2, data_size); |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
943
diff
changeset
|
142 |
EC_WRITE_U8 (data + 4, control); |
628
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
143 |
EC_WRITE_U8 (data + 5, 0x00); // status byte (read only) |
943
1d9e2663e087
Enable sync managers only if SII enable is set and size is greater zero.
Florian Pose <fp@igh-essen.com>
parents:
912
diff
changeset
|
144 |
EC_WRITE_U16(data + 6, enable); |
628
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
145 |
} |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
|
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
/*****************************************************************************/ |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
148 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
149 |
/** Adds a PDO to the list of known mapped PDOs. |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
150 |
* |
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
748
diff
changeset
|
151 |
* \return 0 on success, else < 0 |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
152 |
*/ |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
153 |
int ec_sync_add_pdo( |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
154 |
ec_sync_t *sync, /**< EtherCAT sync manager. */ |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
155 |
const ec_pdo_t *pdo /**< PDO to map. */ |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
156 |
) |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
157 |
{ |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
158 |
return ec_pdo_list_add_pdo_copy(&sync->pdos, pdo); |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
159 |
} |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
160 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
161 |
/*****************************************************************************/ |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
162 |
|
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
943
diff
changeset
|
163 |
/** Determines the default direction from the control register. |
2522
ec403cf308eb
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2123
diff
changeset
|
164 |
* |
ec403cf308eb
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2123
diff
changeset
|
165 |
* \return Direction. |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
166 |
*/ |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
943
diff
changeset
|
167 |
ec_direction_t ec_sync_default_direction( |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
168 |
const ec_sync_t *sync /**< EtherCAT sync manager. */ |
748
6c8801bd547f
Added ec_sync_get_pdo_type().
Florian Pose <fp@igh-essen.com>
parents:
746
diff
changeset
|
169 |
) |
6c8801bd547f
Added ec_sync_get_pdo_type().
Florian Pose <fp@igh-essen.com>
parents:
746
diff
changeset
|
170 |
{ |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
943
diff
changeset
|
171 |
switch ((sync->control_register & 0x0C) >> 2) { |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
943
diff
changeset
|
172 |
case 0x0: return EC_DIR_INPUT; |
1060
5e51425da89f
Fixed sync manager direction bug.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
173 |
case 0x1: return EC_DIR_OUTPUT; |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
943
diff
changeset
|
174 |
default: return EC_DIR_INVALID; |
748
6c8801bd547f
Added ec_sync_get_pdo_type().
Florian Pose <fp@igh-essen.com>
parents:
746
diff
changeset
|
175 |
} |
6c8801bd547f
Added ec_sync_get_pdo_type().
Florian Pose <fp@igh-essen.com>
parents:
746
diff
changeset
|
176 |
} |
6c8801bd547f
Added ec_sync_get_pdo_type().
Florian Pose <fp@igh-essen.com>
parents:
746
diff
changeset
|
177 |
|
6c8801bd547f
Added ec_sync_get_pdo_type().
Florian Pose <fp@igh-essen.com>
parents:
746
diff
changeset
|
178 |
/*****************************************************************************/ |