include/ecrt.h
changeset 923 a6b51990e7e6
parent 916 db73994fbdac
child 925 939f3e9bba1e
equal deleted inserted replaced
922:fede1d8f5b71 923:a6b51990e7e6
    55  *   ecrt_slave_config_state().
    55  *   ecrt_slave_config_state().
    56  * - Process data memory for a domain can now be allocated externally. This
    56  * - Process data memory for a domain can now be allocated externally. This
    57  *   offers the possibility to use a shared-memory region. Therefore,
    57  *   offers the possibility to use a shared-memory region. Therefore,
    58  *   added the domain methods ecrt_domain_size() and
    58  *   added the domain methods ecrt_domain_size() and
    59  *   ecrt_domain_external_memory().
    59  *   ecrt_domain_external_memory().
    60  * - Replaced the process data pointers in the Pdo entry registration
    60  * - PDO registration functions do not return a process data pointer any
    61  *   functions with a process data offset, that is now returned either byte-
    61  *   more. Instead an offset is returned by the funtion. In addition, an 
    62  *   or bitwise by ecrt_slave_config_reg_pdo_entry() or
    62  *   optional bit position can be requested.
    63  *   ecrt_slave_config_reg_pdo_entry_bitwise(), respectively. This was
    63  *   This was necessary for the external domain memory. An additional 
    64  *   necessary for the external domain memory. An additional advantage is,
    64  *   advantage is, that the returned offset is immediately valid. 
    65  *   that the returned offset is immediately valid. If the domain's
    65  *   If the domain's process data is allocated internally, the start 
    66  *   process data is allocated internally, the start address can be retrieved
    66  *   address can be retrieved with ecrt_domain_data().
    67  *   with ecrt_domain_data().
       
    68  * - Replaced ecrt_slave_pdo_mapping/add/clear() with
    67  * - Replaced ecrt_slave_pdo_mapping/add/clear() with
    69  *   ecrt_slave_config_pdo_assign_add() to add a Pdo to a sync manager's Pdo
    68  *   ecrt_slave_config_pdo_assign_add() to add a Pdo to a sync manager's Pdo
    70  *   assignment and ecrt_slave_config_pdo_mapping_add() to add a Pdo entry to a
    69  *   assignment and ecrt_slave_config_pdo_mapping_add() to add a Pdo entry to a
    71  *   Pdo's mapping. ecrt_slave_config_pdos() is a convenience function
    70  *   Pdo's mapping. ecrt_slave_config_pdos() is a convenience function
    72  *   for both, that uses the new data types ec_pdo_info_t and
    71  *   for both, that uses the new data types ec_pdo_info_t and
   238 /*****************************************************************************/
   237 /*****************************************************************************/
   239 
   238 
   240 /** List record type for Pdo entry mass-registration.
   239 /** List record type for Pdo entry mass-registration.
   241  *
   240  *
   242  * This type is used for the array parameter of the
   241  * This type is used for the array parameter of the
   243  * ecrt_domain_reg_pdo_entry_list() and
   242  * ecrt_domain_reg_pdo_entry_list()
   244  * ecrt_domain_reg_pdo_entry_list_bitwise() convenience functions.
       
   245  */
   243  */
   246 typedef struct {
   244 typedef struct {
   247     uint16_t alias; /**< Slave alias address. */
   245     uint16_t alias; /**< Slave alias address. */
   248     uint16_t position; /**< Slave position. */
   246     uint16_t position; /**< Slave position. */
   249     uint32_t vendor_id; /**< Slave vendor ID. */
   247     uint32_t vendor_id; /**< Slave vendor ID. */
   251     uint16_t index; /**< Pdo entry index. */
   249     uint16_t index; /**< Pdo entry index. */
   252     uint8_t subindex; /**< Pdo entry subindex. */
   250     uint8_t subindex; /**< Pdo entry subindex. */
   253     unsigned int *offset; /**< Pointer to a variable to store the Pdo's
   251     unsigned int *offset; /**< Pointer to a variable to store the Pdo's
   254                        offset in the process data. This can either be byte-
   252                        offset in the process data. This can either be byte-
   255                        or bitwise, depending on whether
   253                        or bitwise, depending on whether
   256                        ecrt_domain_reg_pdo_entry_list() or
   254                        ecrt_domain_reg_pdo_entry_list() */
   257                        ecrt_domain_reg_pdo_entry_list_bitwise() was called. */
   255     unsigned int *bitposition; /** Pointer to variable to store a bit 
       
   256                                  position within the address. Can be NULL,
       
   257                                 in which case an error is raised if the 
       
   258                                 PDO does not byte-align. */
   258 } ec_pdo_entry_reg_t;
   259 } ec_pdo_entry_reg_t;
   259 
   260 
   260 /*****************************************************************************/
   261 /*****************************************************************************/
   261 
   262 
   262 /** Sdo request state.
   263 /** Sdo request state.
   517  * Searches the current Pdo assignment and Pdo mappings for the given Pdo
   518  * Searches the current Pdo assignment and Pdo mappings for the given Pdo
   518  * entry. An error is raised, if the given entry is not mapped. Otherwise, the
   519  * entry. An error is raised, if the given entry is not mapped. Otherwise, the
   519  * corresponding sync manager and FMMU configurations are provided for slave
   520  * corresponding sync manager and FMMU configurations are provided for slave
   520  * configuration and the respective sync manager's assigned Pdos are appended
   521  * configuration and the respective sync manager's assigned Pdos are appended
   521  * to the given domain, if not already done. The offset of the requested Pdo
   522  * to the given domain, if not already done. The offset of the requested Pdo
   522  * entry's data inside the domain's process data is returned.
   523  * entry's data inside the domain's process data is returned. Optionally, the
       
   524  * Pdo entry bit position can be retrieved if a non-null pointer is passed
       
   525  * to the \a bitposition parameter. If this is null, an error is raised if
       
   526  * the Pdo entry does not byte align.
   523  *
   527  *
   524  * \retval >=0 Success: Offset of the Pdo entry's process data.
   528  * \retval >=0 Success: Offset of the Pdo entry's process data.
   525  * \retval -1  Error: Pdo entry not found.
   529  * \retval -1  Error: Pdo entry not found.
   526  * \retval -2  Error: Failed to register Pdo entry.
   530  * \retval -2  Error: Failed to register Pdo entry.
   527  * \retval -3  Error: Pdo entry is not byte-aligned.
   531  * \retval -3  Error: Pdo entry is not byte-aligned.
   528  */
   532  */
   529 int ecrt_slave_config_reg_pdo_entry(
   533 int ecrt_slave_config_reg_pdo_entry(
   530         ec_slave_config_t *sc, /**< Slave configuration. */
   534         ec_slave_config_t *sc, /**< Slave configuration. */
   531         uint16_t entry_index, /**< Index of the Pdo entry to register. */
   535         uint16_t entry_index, /**< Index of the Pdo entry to register. */
   532         uint8_t entry_subindex, /**< Subindex of the Pdo entry to register. */
   536         uint8_t entry_subindex, /**< Subindex of the Pdo entry to register. */
   533         ec_domain_t *domain /**< Domain. */
   537         ec_domain_t *domain, /**< Domain. */
   534         );
   538         unsigned int *bitposition /**< Optional address if bit addressing 
   535 
   539                                  is desired */
   536 /** Registers a Pdo entry for process data exchange in a domain.
       
   537  *
       
   538  * Bitwise registration function.
       
   539  *
       
   540  * \see ecrt_slave_config_reg_pdo_entry().
       
   541  *
       
   542  * \retval >=0 Success: Bit offset of the Pdo entry's process data.
       
   543  * \retval -1  Error: Pdo entry not found.
       
   544  * \retval -2  Error: Failed to register Pdo entry.
       
   545  */
       
   546 int ecrt_slave_config_reg_pdo_entry_bitwise(
       
   547         ec_slave_config_t *sc, /**< Slave configuration. */
       
   548         uint16_t entry_index, /**< Index of the Pdo entry to register. */
       
   549         uint8_t entry_subindex, /**< Subindex of the Pdo entry to register. */
       
   550         ec_domain_t *domain /**< Domain. */
       
   551         );
   540         );
   552 
   541 
   553 /** Add an Sdo configuration.
   542 /** Add an Sdo configuration.
   554  *
   543  *
   555  * An Sdo configuration is stored in the slave configuration object and is
   544  * An Sdo configuration is stored in the slave configuration object and is
   640  * \attention The registration array has to be terminated with an empty
   629  * \attention The registration array has to be terminated with an empty
   641  *            structure, or one with the \a index field set to zero!
   630  *            structure, or one with the \a index field set to zero!
   642  * \return 0 on success, else non-zero.
   631  * \return 0 on success, else non-zero.
   643  */
   632  */
   644 int ecrt_domain_reg_pdo_entry_list(
   633 int ecrt_domain_reg_pdo_entry_list(
   645         ec_domain_t *domain, /**< Domain. */
       
   646         const ec_pdo_entry_reg_t *pdo_entry_regs /**< Array of Pdo
       
   647                                                    registrations. */
       
   648         );
       
   649 
       
   650 /** Registers a bunch of Pdo entries for a domain.
       
   651  *
       
   652  * Bitwise registration.
       
   653  *
       
   654  * \see ecrt_domain_reg_pdo_entry_list()
       
   655  *
       
   656  * \attention The registration array has to be terminated with an empty
       
   657  *            structure, or one with the \a index field set to zero!
       
   658  * \return 0 on success, else non-zero.
       
   659  */
       
   660 int ecrt_domain_reg_pdo_entry_list_bitwise(
       
   661         ec_domain_t *domain, /**< Domain. */
   634         ec_domain_t *domain, /**< Domain. */
   662         const ec_pdo_entry_reg_t *pdo_entry_regs /**< Array of Pdo
   635         const ec_pdo_entry_reg_t *pdo_entry_regs /**< Array of Pdo
   663                                                    registrations. */
   636                                                    registrations. */
   664         );
   637         );
   665 
   638