diff --git a/master/master.c b/master/master.c index 327c6cc430fd0045ef691c6934a512c6fb823a9e..3b9dcde5ae560d844f719d62912374e956d4a2c1 100644 --- a/master/master.c +++ b/master/master.c @@ -1124,20 +1124,35 @@ unsigned int ec_master_domain_count( /*****************************************************************************/ +#define EC_FIND_DOMAIN \ + do { \ + list_for_each_entry(domain, &master->domains, list) { \ + if (index--) \ + continue; \ + return domain; \ + } \ + \ + return NULL; \ + } while (0) + ec_domain_t *ec_master_find_domain( ec_master_t *master, /**< EtherCAT master. */ unsigned int index /**< Domain index. */ ) { ec_domain_t *domain; + EC_FIND_DOMAIN; +} - list_for_each_entry(domain, &master->domains, list) { - if (index--) - continue; - return domain; - } +/*****************************************************************************/ - return NULL; +const ec_domain_t *ec_master_find_domain_const( + const ec_master_t *master, /**< EtherCAT master. */ + unsigned int index /**< Domain index. */ + ) +{ + const ec_domain_t *domain; + EC_FIND_DOMAIN; } /*****************************************************************************/ diff --git a/master/master.h b/master/master.h index d5ccc6c578d5d9fcd28874dcc95346dfe35ad8ee..8208aa12c2b8808d5dfbb05e69de9b5f9eb6338d 100644 --- a/master/master.h +++ b/master/master.h @@ -203,6 +203,8 @@ const ec_slave_config_t *ec_master_get_config_const( const ec_master_t *, unsigned int); unsigned int ec_master_domain_count(const ec_master_t *); ec_domain_t *ec_master_find_domain(ec_master_t *, unsigned int); +const ec_domain_t *ec_master_find_domain_const(const ec_master_t *, + unsigned int); int ec_master_debug_level(ec_master_t *, int);