Introduced ec_slave_get_pdo_sync().
--- a/master/domain.c Tue Mar 06 09:06:01 2007 +0000
+++ b/master/domain.c Tue Mar 06 09:15:12 2007 +0000
@@ -266,22 +266,12 @@
{
ec_data_reg_t *data_reg;
ec_sii_sync_t *sync;
- unsigned int sync_index;
uint16_t sync_length;
- switch (dir) { // FIXME
- case EC_DIR_OUTPUT: sync_index = 2; break;
- case EC_DIR_INPUT: sync_index = 3; break;
- default:
- EC_ERR("Invalid direction!\n");
- return -1;
- }
-
- if (sync_index >= slave->sii_sync_count) {
+ if (!(sync = ec_slave_get_pdo_sync(slave, dir))) {
EC_ERR("No sync manager found for PDO range.\n");
return -1;
}
- sync = &slave->sii_syncs[sync_index];
// Allocate memory for data registration object
if (!(data_reg =
--- a/master/slave.c Tue Mar 06 09:06:01 2007 +0000
+++ b/master/slave.c Tue Mar 06 09:15:12 2007 +0000
@@ -1114,6 +1114,36 @@
/*****************************************************************************/
/**
+ */
+
+ec_sii_sync_t *ec_slave_get_pdo_sync(
+ ec_slave_t *slave, /**< EtherCAT slave */
+ ec_direction_t dir /**< input or output */
+ )
+{
+ unsigned int sync_index;
+
+ switch (dir) {
+ case EC_DIR_OUTPUT: sync_index = 0; break;
+ case EC_DIR_INPUT: sync_index = 1; break;
+ default:
+ EC_ERR("Invalid direction!\n");
+ return NULL;
+ }
+
+ if (slave->sii_mailbox_protocols) sync_index += 2;
+
+ if (sync_index >= slave->sii_sync_count) {
+ EC_ERR("No appropriate sync manager found.\n");
+ return NULL;
+ }
+
+ return &slave->sii_syncs[sync_index];
+}
+
+/*****************************************************************************/
+
+/**
Initializes a sync manager configuration page with EEPROM data.
The referenced memory (\a data) must be at least EC_SYNC_SIZE bytes.
*/
--- a/master/slave.h Tue Mar 06 09:06:01 2007 +0000
+++ b/master/slave.h Tue Mar 06 09:15:12 2007 +0000
@@ -284,6 +284,7 @@
int ec_slave_locate_string(ec_slave_t *, unsigned int, char **);
// misc.
+ec_sii_sync_t *ec_slave_get_pdo_sync(ec_slave_t *, ec_direction_t);
void ec_slave_sync_config(const ec_slave_t *, const ec_sii_sync_t *,
uint8_t *);
void ec_slave_fmmu_config(const ec_slave_t *, const ec_fmmu_t *, uint8_t *);