# HG changeset patch # User Florian Pose # Date 1203587454 0 # Node ID f8bca95ab75d3f1ab33ae345b4c83a7c8a42547c # Parent ab8daaabbe48dcc40c59868c6ceb7647a5656fec Moved ecrt_domain_reg_pdo_entry() to ecrt_slave_config_reg_pdo_entry(). diff -r ab8daaabbe48 -r f8bca95ab75d include/ecrt.h --- a/include/ecrt.h Thu Feb 21 09:24:56 2008 +0000 +++ b/include/ecrt.h Thu Feb 21 09:50:54 2008 +0000 @@ -50,7 +50,7 @@ * - Replaced slave address string with alias and position values. See * ecrt_master_slave_config(). * - Removed ecrt_master_get_slave_by_pos(), because it is no longer - * necessary (alias/position, slave configurations). + * necessary due to alias/position addressing. * - Added ec_slave_config_state_t for the new method * ecrt_slave_config_state(). * - Process data memory for a domain can now be allocated externally. This @@ -58,9 +58,10 @@ * added the domain methods ecrt_domain_size() and ecrt_domain_memory(). * - Replaced the process data pointers in the Pdo entry registration * functions with a process data offset, that is now returned by - * ecrt_domain_reg_pdo_entry(). This was necessary for the external + * ecrt_slave_config_reg_pdo_entry(). This was necessary for the external * domain memory. An additional advantage is, that the returned offset value - * is directly usable. + * is directly usable. The domain's process data offset can be retrieved + * with ecrt_domain_data(). * - Replaced ecrt_slave_pdo_mapping/add/clear() with * ecrt_slave_config_mapping() that is now able to specify Pdo mapping and * Pdo configuration. Pdo entries mapped in this way can now immediately be @@ -73,7 +74,7 @@ * of ecrt_domain_state(). * - Former "Pdo registration" meant Pdo entry registration in fact, therefore * renamed ec_pdo_reg_t to ec_pdo_entry_reg_t and ecrt_domain_register_pdo() - * to ecrt_domain_reg_pdo_entry(). + * to ecrt_slave_config_reg_pdo_entry(). * - Removed ecrt_domain_register_pdo_range(), because it's functionality can * be reached by specifying an explicit Pdo mapping and registering those * Pdo entries. @@ -415,6 +416,23 @@ const ec_pdo_info_t pdos[] /**< List with Pdo mapping. */ ); +/** Registers a Pdo entry of the given slave configuration at a domain. + * + * Searches the mapping and the Pdo configurations for the given Pdo entry. If + * found, the curresponding sync manager/FMMU is added to the domain and the + * offset of the Pdo entry's data in the domain process data is returned. + * + * \retval >=0 Offset of the Pdo entry's process data. + * \retval -1 Pdo entry not found. + * \retval -2 Failed to register Pdo entry. + */ +int ecrt_slave_config_reg_pdo_entry( + ec_slave_config_t *sc, /**< Slave configuration. */ + uint16_t entry_index, /**< Index of the Pdo entry to register. */ + uint8_t entry_subindex, /**< Subindex of the Pdo entry to register. */ + ec_domain_t *domain /**< Domain. */ + ); + /** Add a configuration value for an 8-bit SDO. * * \todo doc @@ -464,20 +482,6 @@ * Domain methods *****************************************************************************/ -/** Registers a single Pdo entry for a domain. - * - * \return On success, the function returns the offset in the domain's process - * data, which can be zero or greater. On failure, it returns a value - * less than zero. - */ - -int ecrt_domain_reg_pdo_entry( - ec_domain_t *domain, /**< Domain. */ - ec_slave_config_t *sc, /**< Slave configuration. */ - uint16_t entry_index, /**< Index of the Pdo entry to register. */ - uint8_t entry_subindex /**< Subindex of the Pdo entry to register. */ - ); - /** Registers a bunch of Pdo entries for a domain. * * \todo doc diff -r ab8daaabbe48 -r f8bca95ab75d master/domain.c --- a/master/domain.c Thu Feb 21 09:24:56 2008 +0000 +++ b/master/domain.c Thu Feb 21 09:50:54 2008 +0000 @@ -278,14 +278,6 @@ * Realtime interface *****************************************************************************/ -int ecrt_domain_reg_pdo_entry(ec_domain_t *domain, ec_slave_config_t *sc, - uint16_t index, uint8_t subindex) -{ - return ec_slave_config_reg_pdo_entry(sc, domain, index, subindex); -} - -/*****************************************************************************/ - int ecrt_domain_reg_pdo_entry_list(ec_domain_t *domain, const ec_pdo_entry_reg_t *regs) { @@ -298,8 +290,8 @@ reg->position, reg->vendor_id, reg->product_code))) return -1; - if ((ret = ecrt_domain_reg_pdo_entry(domain, sc, reg->index, - reg->subindex)) < 0) + if ((ret = ecrt_slave_config_reg_pdo_entry(sc, reg->index, + reg->subindex, domain)) < 0) return -1; *reg->offset = ret; @@ -371,7 +363,6 @@ /** \cond */ -EXPORT_SYMBOL(ecrt_domain_reg_pdo_entry); EXPORT_SYMBOL(ecrt_domain_reg_pdo_entry_list); //EXPORT_SYMBOL(ecrt_domain_size); //EXPORT_SYMBOL(ecrt_domain_memory); diff -r ab8daaabbe48 -r f8bca95ab75d master/slave_config.c --- a/master/slave_config.c Thu Feb 21 09:24:56 2008 +0000 +++ b/master/slave_config.c Thu Feb 21 09:50:54 2008 +0000 @@ -221,57 +221,6 @@ /*****************************************************************************/ -/** Registers a Pdo entry. - * - * Searches the mapping and the Pdo configurations for the given Pdo entry. If - * found, the curresponding sync manager/FMMU is added to the domain and the - * offset of the Pdo entry's data in the domain process data is returned. - * - * \retval >=0 Offset of the Pdo entry's process data. - * \retval -1 Pdo entry not found. - * \retval -2 Failed to register Pdo entry. - */ -int ec_slave_config_reg_pdo_entry( - ec_slave_config_t *sc, /**< Slave configuration. */ - ec_domain_t *domain, /**< Domain. */ - uint16_t index, /**< Index of Pdo entry to register. */ - uint8_t subindex /**< Subindex of Pdo entry to register. */ - ) -{ - ec_direction_t dir; - ec_pdo_mapping_t *map; - unsigned int bit_offset, byte_offset; - ec_pdo_t *pdo; - ec_pdo_entry_t *entry; - int ret; - - for (dir = EC_DIR_OUTPUT; dir <= EC_DIR_INPUT; dir++) { - map = &sc->mapping[dir]; - bit_offset = 0; - list_for_each_entry(pdo, &map->pdos, list) { - list_for_each_entry(entry, &pdo->entries, list) { - if (entry->index != index || entry->subindex != subindex) { - bit_offset += entry->bit_length; - } else { - goto found; - } - } - } - } - - EC_ERR("PDO entry 0x%04X:%u is not mapped in slave config %u:%u.\n", - index, subindex, sc->alias, sc->position); - return -1; - -found: - byte_offset = bit_offset / 8; - if ((ret = ec_slave_config_prepare_fmmu(sc, domain, dir)) < 0) - return -2; - return ret + byte_offset; -} - -/*****************************************************************************/ - /** Outputs all information about a certain slave configuration. */ ssize_t ec_slave_config_info( @@ -504,6 +453,47 @@ /*****************************************************************************/ +int ecrt_slave_config_reg_pdo_entry( + ec_slave_config_t *sc, /**< Slave configuration. */ + uint16_t index, /**< Index of Pdo entry to register. */ + uint8_t subindex, /**< Subindex of Pdo entry to register. */ + ec_domain_t *domain /**< Domain. */ + ) +{ + ec_direction_t dir; + ec_pdo_mapping_t *map; + unsigned int bit_offset, byte_offset; + ec_pdo_t *pdo; + ec_pdo_entry_t *entry; + int ret; + + for (dir = EC_DIR_OUTPUT; dir <= EC_DIR_INPUT; dir++) { + map = &sc->mapping[dir]; + bit_offset = 0; + list_for_each_entry(pdo, &map->pdos, list) { + list_for_each_entry(entry, &pdo->entries, list) { + if (entry->index != index || entry->subindex != subindex) { + bit_offset += entry->bit_length; + } else { + goto found; + } + } + } + } + + EC_ERR("PDO entry 0x%04X:%u is not mapped in slave config %u:%u.\n", + index, subindex, sc->alias, sc->position); + return -1; + +found: + byte_offset = bit_offset / 8; + if ((ret = ec_slave_config_prepare_fmmu(sc, domain, dir)) < 0) + return -2; + return ret + byte_offset; +} + +/*****************************************************************************/ + int ecrt_slave_config_sdo8(ec_slave_config_t *slave, uint16_t index, uint8_t subindex, uint8_t value) { @@ -537,6 +527,7 @@ /** \cond */ EXPORT_SYMBOL(ecrt_slave_config_mapping); +EXPORT_SYMBOL(ecrt_slave_config_reg_pdo_entry); EXPORT_SYMBOL(ecrt_slave_config_sdo8); EXPORT_SYMBOL(ecrt_slave_config_sdo16); EXPORT_SYMBOL(ecrt_slave_config_sdo32);