191 * |
191 * |
192 * Configuration data for the FMMU is saved in the slave config structure and |
192 * Configuration data for the FMMU is saved in the slave config structure and |
193 * is written to the slave during the configuration. The FMMU configuration |
193 * is written to the slave during the configuration. The FMMU configuration |
194 * is done in a way, that the complete data range of the corresponding sync |
194 * is done in a way, that the complete data range of the corresponding sync |
195 * manager is covered. Seperate FMMUs are configured for each domain. If the |
195 * manager is covered. Seperate FMMUs are configured for each domain. If the |
196 * FMMU configuration is already prepared, the function returns with success. |
196 * FMMU configuration is already prepared, the function does nothing and |
197 * |
197 * returns with success. |
198 * \retval >=0 Logical offset address. |
198 * |
199 * \retval -1 FMMU limit reached. |
199 * \retval >=0 Success, logical offset byte address. |
|
200 * \retval -1 Error, FMMU limit reached. |
200 */ |
201 */ |
201 int ec_slave_config_prepare_fmmu( |
202 int ec_slave_config_prepare_fmmu( |
202 ec_slave_config_t *sc, /**< Slave configuration. */ |
203 ec_slave_config_t *sc, /**< Slave configuration. */ |
203 ec_domain_t *domain, /**< Domain. */ |
204 ec_domain_t *domain, /**< Domain. */ |
204 ec_direction_t dir /**< Pdo direction. */ |
205 ec_direction_t dir /**< Pdo direction. */ |
607 uint16_t index, /**< Index of Pdo entry to register. */ |
608 uint16_t index, /**< Index of Pdo entry to register. */ |
608 uint8_t subindex, /**< Subindex of Pdo entry to register. */ |
609 uint8_t subindex, /**< Subindex of Pdo entry to register. */ |
609 ec_domain_t *domain /**< Domain. */ |
610 ec_domain_t *domain /**< Domain. */ |
610 ) |
611 ) |
611 { |
612 { |
|
613 int ret = ecrt_slave_config_reg_pdo_entry_bitwise( |
|
614 sc, index, subindex, domain); |
|
615 |
|
616 if (ret < 0) |
|
617 return ret; |
|
618 |
|
619 if (ret % 8) { |
|
620 EC_ERR("Bytewise Pdo entry registration requested, but the result is " |
|
621 "not byte-aligned.\n"); |
|
622 return -3; |
|
623 } |
|
624 |
|
625 return ret / 8; |
|
626 } |
|
627 |
|
628 /*****************************************************************************/ |
|
629 |
|
630 int ecrt_slave_config_reg_pdo_entry_bitwise( |
|
631 ec_slave_config_t *sc, /**< Slave configuration. */ |
|
632 uint16_t index, /**< Index of Pdo entry to register. */ |
|
633 uint8_t subindex, /**< Subindex of Pdo entry to register. */ |
|
634 ec_domain_t *domain /**< Domain. */ |
|
635 ) |
|
636 { |
612 ec_direction_t dir; |
637 ec_direction_t dir; |
613 ec_pdo_list_t *pdos; |
638 ec_pdo_list_t *pdos; |
614 unsigned int bit_offset, byte_offset; |
639 unsigned int bit_offset; |
615 ec_pdo_t *pdo; |
640 ec_pdo_t *pdo; |
616 ec_pdo_entry_t *entry; |
641 ec_pdo_entry_t *entry; |
617 int ret; |
642 int ret; |
618 |
643 |
619 for (dir = EC_DIR_OUTPUT; dir <= EC_DIR_INPUT; dir++) { |
644 for (dir = EC_DIR_OUTPUT; dir <= EC_DIR_INPUT; dir++) { |
633 EC_ERR("Pdo entry 0x%04X:%u is not mapped in slave config %u:%u.\n", |
658 EC_ERR("Pdo entry 0x%04X:%u is not mapped in slave config %u:%u.\n", |
634 index, subindex, sc->alias, sc->position); |
659 index, subindex, sc->alias, sc->position); |
635 return -1; |
660 return -1; |
636 |
661 |
637 found: |
662 found: |
638 byte_offset = bit_offset / 8; |
|
639 if ((ret = ec_slave_config_prepare_fmmu(sc, domain, dir)) < 0) |
663 if ((ret = ec_slave_config_prepare_fmmu(sc, domain, dir)) < 0) |
640 return -2; |
664 return -2; |
641 return ret + byte_offset; |
665 return ret * 8 + bit_offset; |
642 } |
666 } |
643 |
667 |
644 /*****************************************************************************/ |
668 /*****************************************************************************/ |
645 |
669 |
646 int ecrt_slave_config_sdo(ec_slave_config_t *sc, uint16_t index, |
670 int ecrt_slave_config_sdo(ec_slave_config_t *sc, uint16_t index, |