Some improvements concerning bit_position.
This commit is contained in:
parent
48c078359d
commit
e6f758b4de
|
|
@ -57,13 +57,12 @@
|
||||||
* offers the possibility to use a shared-memory region. Therefore,
|
* offers the possibility to use a shared-memory region. Therefore,
|
||||||
* added the domain methods ecrt_domain_size() and
|
* added the domain methods ecrt_domain_size() and
|
||||||
* ecrt_domain_external_memory().
|
* ecrt_domain_external_memory().
|
||||||
* - PDO registration functions do not return a process data pointer any
|
* - Pdo entry registration functions do not return a process data pointer,
|
||||||
* more. Instead an offset is returned by the funtion. In addition, an
|
* but an offset in the domain's process data. In addition, an optional bit
|
||||||
* optional bit position can be requested.
|
* position can be requested. This was necessary for the external domain
|
||||||
* This was necessary for the external domain memory. An additional
|
* memory. An additional advantage is, that the returned offset is
|
||||||
* advantage is, that the returned offset is immediately valid.
|
* immediately valid. If the domain's process data is allocated internally,
|
||||||
* If the domain's process data is allocated internally, the start
|
* the start address can be retrieved with ecrt_domain_data().
|
||||||
* address can be retrieved with ecrt_domain_data().
|
|
||||||
* - Replaced ecrt_slave_pdo_mapping/add/clear() with
|
* - Replaced ecrt_slave_pdo_mapping/add/clear() with
|
||||||
* ecrt_slave_config_pdo_assign_add() to add a Pdo to a sync manager's Pdo
|
* ecrt_slave_config_pdo_assign_add() to add a Pdo to a sync manager's Pdo
|
||||||
* assignment and ecrt_slave_config_pdo_mapping_add() to add a Pdo entry to a
|
* assignment and ecrt_slave_config_pdo_mapping_add() to add a Pdo entry to a
|
||||||
|
|
@ -81,8 +80,8 @@
|
||||||
* renamed ec_pdo_reg_t to ec_pdo_entry_reg_t and ecrt_domain_register_pdo()
|
* renamed ec_pdo_reg_t to ec_pdo_entry_reg_t and ecrt_domain_register_pdo()
|
||||||
* to ecrt_slave_config_reg_pdo_entry().
|
* to ecrt_slave_config_reg_pdo_entry().
|
||||||
* - Removed ecrt_domain_register_pdo_range(), because it's functionality can
|
* - Removed ecrt_domain_register_pdo_range(), because it's functionality can
|
||||||
* be reached by specifying an explicit Pdo mapping and registering those
|
* be reached by specifying an explicit Pdo assignment/mapping and
|
||||||
* Pdo entries.
|
* registering the mapped Pdo entries.
|
||||||
* - Added an Sdo access interface, working with Sdo requests. These can be
|
* - Added an Sdo access interface, working with Sdo requests. These can be
|
||||||
* scheduled for reading and writing during realtime operation.
|
* scheduled for reading and writing during realtime operation.
|
||||||
* - Exported ecrt_slave_config_sdo(), the generic Sdo configuration function.
|
* - Exported ecrt_slave_config_sdo(), the generic Sdo configuration function.
|
||||||
|
|
@ -126,7 +125,7 @@
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** End of the Pdo list.
|
/** End of the Pdo entry list.
|
||||||
*
|
*
|
||||||
* This is used in ecrt_slave_config_pdos().
|
* This is used in ecrt_slave_config_pdos().
|
||||||
*/
|
*/
|
||||||
|
|
@ -177,9 +176,10 @@ typedef struct {
|
||||||
* This is used in ec_domain_state_t.
|
* This is used in ec_domain_state_t.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
EC_WC_ZERO = 0, /**< No Pdos were exchanged. */
|
EC_WC_ZERO = 0, /**< No registered process data were exchanged. */
|
||||||
EC_WC_INCOMPLETE, /**< Some of the registered Pdos were exchanged. */
|
EC_WC_INCOMPLETE, /**< Some of the registered process data were
|
||||||
EC_WC_COMPLETE /**< All registered Pdos were exchanged. */
|
exchanged. */
|
||||||
|
EC_WC_COMPLETE /**< All registered process data were exchanged. */
|
||||||
} ec_wc_state_t;
|
} ec_wc_state_t;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -195,7 +195,7 @@ typedef struct {
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/** Direction type for Pdo mapping functions.
|
/** Direction type for Pdo assignment functions.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
EC_DIR_OUTPUT, /**< Values written by the master. */
|
EC_DIR_OUTPUT, /**< Values written by the master. */
|
||||||
|
|
@ -211,9 +211,8 @@ typedef enum {
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t index; /**< Index of the Pdo entry to add to the Pdo
|
uint16_t index; /**< Index of the Pdo entry to add to the Pdo
|
||||||
configuration. */
|
mapping. */
|
||||||
uint8_t subindex; /**< Subindex of the Pdo entry to add to the
|
uint8_t subindex; /**< Subindex of the Pdo entry. */
|
||||||
Pdo configuration. */
|
|
||||||
uint8_t bit_length; /**< Size of the Pdo entry in bit. */
|
uint8_t bit_length; /**< Size of the Pdo entry in bit. */
|
||||||
} ec_pdo_entry_info_t;
|
} ec_pdo_entry_info_t;
|
||||||
|
|
||||||
|
|
@ -226,10 +225,11 @@ typedef struct {
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ec_direction_t dir; /**< Pdo direction (input/output). */
|
ec_direction_t dir; /**< Pdo direction (input/output). */
|
||||||
uint16_t index; /**< Index of the Pdo to map. */
|
uint16_t index; /**< Index of the Pdo to assign. */
|
||||||
unsigned int n_entries; /**< Number of Pdo entries in \a entries to map.
|
unsigned int n_entries; /**< Number of Pdo entries in \a entries to map.
|
||||||
Zero means, that the default mapping shall be
|
Zero means, that the default mapping shall be
|
||||||
used. */
|
used (this can only be done if the slave is
|
||||||
|
present at bus configuration time). */
|
||||||
ec_pdo_entry_info_t *entries; /**< Array of Pdo entries to map. This must
|
ec_pdo_entry_info_t *entries; /**< Array of Pdo entries to map. This must
|
||||||
contain at least \a n_entries values. */
|
contain at least \a n_entries values. */
|
||||||
} ec_pdo_info_t;
|
} ec_pdo_info_t;
|
||||||
|
|
@ -248,14 +248,12 @@ typedef struct {
|
||||||
uint32_t product_code; /**< Slave product code. */
|
uint32_t product_code; /**< Slave product code. */
|
||||||
uint16_t index; /**< Pdo entry index. */
|
uint16_t index; /**< Pdo entry index. */
|
||||||
uint8_t subindex; /**< Pdo entry subindex. */
|
uint8_t subindex; /**< Pdo entry subindex. */
|
||||||
unsigned int *offset; /**< Pointer to a variable to store the Pdo's
|
unsigned int *offset; /**< Pointer to a variable to store the Pdo entry's
|
||||||
offset in the process data. This can either be byte-
|
(byte-)offset in the process data. */
|
||||||
or bitwise, depending on whether
|
unsigned int *bit_position; /** Pointer to a variable to store a bit
|
||||||
ecrt_domain_reg_pdo_entry_list() */
|
position (0-7) within the \a offset. Can be
|
||||||
unsigned int *bitposition; /** Pointer to variable to store a bit
|
NULL, in which case an error is raised if the
|
||||||
position within the address. Can be NULL,
|
Pdo entry does not byte-align. */
|
||||||
in which case an error is raised if the
|
|
||||||
PDO does not byte-align. */
|
|
||||||
} ec_pdo_entry_reg_t;
|
} ec_pdo_entry_reg_t;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -357,12 +355,11 @@ ec_slave_config_t *ecrt_master_slave_config(
|
||||||
|
|
||||||
/** Finishes the configuration phase and prepares for realtime mode.
|
/** Finishes the configuration phase and prepares for realtime mode.
|
||||||
*
|
*
|
||||||
* This function has to be called after all Pdo entries are registered. It
|
* This function tells the master that the configuration phase is finished and
|
||||||
* tells the master that the configuration phase is finished and the realtime
|
* the realtime operation will begin. The function allocates internal memory
|
||||||
* operation will begin. The function allocates internal memory for the
|
* for the domains and calculates the logical FMMU addresses for domain
|
||||||
* domains and calculates the logical FMMU addresses for domain members. It
|
* members. It tells the master state machine that the bus configuration is
|
||||||
* tells the master state machine that the bus configuration is now to be
|
* now to be applied.
|
||||||
* applied.
|
|
||||||
*
|
*
|
||||||
* \attention After this function has been called, the realtime application is
|
* \attention After this function has been called, the realtime application is
|
||||||
* in charge of cyclically calling ecrt_master_send() and
|
* in charge of cyclically calling ecrt_master_send() and
|
||||||
|
|
@ -515,15 +512,15 @@ int ecrt_slave_config_pdos(
|
||||||
|
|
||||||
/** Registers a Pdo entry for process data exchange in a domain.
|
/** Registers a Pdo entry for process data exchange in a domain.
|
||||||
*
|
*
|
||||||
* Searches the current Pdo assignment and Pdo mappings for the given Pdo
|
* Searches the assigned Pdos for the given Pdo entry. An error is raised, if
|
||||||
* entry. An error is raised, if the given entry is not mapped. Otherwise, the
|
* the given entry is not mapped. Otherwise, the corresponding sync manager
|
||||||
* corresponding sync manager and FMMU configurations are provided for slave
|
* and FMMU configurations are provided for slave configuration and the
|
||||||
* configuration and the respective sync manager's assigned Pdos are appended
|
* respective sync manager's assigned Pdos are appended to the given domain,
|
||||||
* to the given domain, if not already done. The offset of the requested Pdo
|
* if not already done. The offset of the requested Pdo entry's data inside
|
||||||
* entry's data inside the domain's process data is returned. Optionally, the
|
* the domain's process data is returned. Optionally, the Pdo entry bit
|
||||||
* Pdo entry bit position can be retrieved if a non-null pointer is passed
|
* position (0-7) can be retrieved via the \a bit_position output parameter.
|
||||||
* to the \a bitposition parameter. If this is null, an error is raised if
|
* This pointer may be \a NULL, in this case an error is raised if the Pdo
|
||||||
* the Pdo entry does not byte align.
|
* entry does not byte-align.
|
||||||
*
|
*
|
||||||
* \retval >=0 Success: Offset of the Pdo entry's process data.
|
* \retval >=0 Success: Offset of the Pdo entry's process data.
|
||||||
* \retval -1 Error: Pdo entry not found.
|
* \retval -1 Error: Pdo entry not found.
|
||||||
|
|
@ -535,7 +532,7 @@ int ecrt_slave_config_reg_pdo_entry(
|
||||||
uint16_t entry_index, /**< Index of the Pdo entry to register. */
|
uint16_t entry_index, /**< Index of the Pdo entry to register. */
|
||||||
uint8_t entry_subindex, /**< Subindex of the Pdo entry to register. */
|
uint8_t entry_subindex, /**< Subindex of the Pdo entry to register. */
|
||||||
ec_domain_t *domain, /**< Domain. */
|
ec_domain_t *domain, /**< Domain. */
|
||||||
unsigned int *bitposition /**< Optional address if bit addressing
|
unsigned int *bit_position /**< Optional address if bit addressing
|
||||||
is desired */
|
is desired */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -390,7 +390,7 @@ int ecrt_domain_reg_pdo_entry_list(ec_domain_t *domain,
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if ((ret = ecrt_slave_config_reg_pdo_entry(sc, reg->index,
|
if ((ret = ecrt_slave_config_reg_pdo_entry(sc, reg->index,
|
||||||
reg->subindex, domain, reg->bitposition)) < 0)
|
reg->subindex, domain, reg->bit_position)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
*reg->offset = ret;
|
*reg->offset = ret;
|
||||||
|
|
|
||||||
|
|
@ -608,12 +608,12 @@ int ecrt_slave_config_reg_pdo_entry(
|
||||||
uint16_t index,
|
uint16_t index,
|
||||||
uint8_t subindex,
|
uint8_t subindex,
|
||||||
ec_domain_t *domain,
|
ec_domain_t *domain,
|
||||||
unsigned int *bitpos
|
unsigned int *bit_position
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ec_direction_t dir;
|
ec_direction_t dir;
|
||||||
ec_pdo_list_t *pdos;
|
ec_pdo_list_t *pdos;
|
||||||
unsigned int bit_offset;
|
unsigned int bit_offset, bit_pos;
|
||||||
ec_pdo_t *pdo;
|
ec_pdo_t *pdo;
|
||||||
ec_pdo_entry_t *entry;
|
ec_pdo_entry_t *entry;
|
||||||
int sync_offset;
|
int sync_offset;
|
||||||
|
|
@ -641,11 +641,12 @@ found:
|
||||||
if (sync_offset < 0)
|
if (sync_offset < 0)
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
if (bitpos) {
|
bit_pos = bit_offset % 8;
|
||||||
*bitpos = bit_offset % 8;
|
if (bit_position) {
|
||||||
} else if (bit_offset % 8) {
|
*bit_position = bit_pos;
|
||||||
EC_ERR("Bytewise Pdo entry registration requested, but the result is "
|
} else if (bit_pos) {
|
||||||
"not byte-aligned.\n");
|
EC_ERR("Pdo entry 0x%04X:%X does not byte-align in config %u:%u.\n",
|
||||||
|
index, subindex, sc->alias, sc->position);
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue