Exported ecrt_slave_config_sdo(); added documentation.
--- a/NEWS Tue Apr 08 11:52:51 2008 +0000
+++ b/NEWS Wed Apr 16 08:33:04 2008 +0000
@@ -46,6 +46,8 @@
Pdo entries.
- Added an Sdo access interface, working with Sdo requests. These can be
scheduled for reading and writing during realtime operation.
+ - Exported ecrt_slave_config_sdo(), the generic Sdo configuration
+ function.
* Pdo configuration is now supported.
* Current Pdo mapping/configuration is now read via CoE during bus scan, using
direct Sdo access, independent of the dictionary.
--- a/include/ecrt.h Tue Apr 08 11:52:51 2008 +0000
+++ b/include/ecrt.h Wed Apr 16 08:33:04 2008 +0000
@@ -84,6 +84,7 @@
* Pdo entries.
* - Added an Sdo access interface, working with Sdo requests. These can be
* scheduled for reading and writing during realtime operation.
+ * - Exported ecrt_slave_config_sdo(), the generic Sdo configuration function.
*
* @{
*/
@@ -541,9 +542,32 @@
ec_domain_t *domain /**< Domain. */
);
+/** Add an Sdo configuration.
+ *
+ * An Sdo configuration is stored in the slave configuration object and is
+ * downloaded to the slave whenever the slave is being configured by the
+ * master. This usually happens once on master activation, but can be repeated
+ * subsequently, for example after the slave's power supply failed.
+ *
+ * This is the generic function for adding an Sdo configuration. Please note
+ * that the this function does not do any endianess correction. If
+ * datatype-specific functions are needed (that automatically correct the
+ * endianess), have a look at ecrt_slave_config_sdo8(),
+ * ecrt_slave_config_sdo16() and ecrt_slave_config_sdo32().
+ *
+ * \return 0 in case of success, else < 0
+ */
+int ecrt_slave_config_sdo(
+ ec_slave_config_t *sc, /**< Slave configuration. */
+ uint16_t index, /**< Index of the Sdo to configure. */
+ uint8_t subindex, /**< Subindex of the Sdo to configure. */
+ const uint8_t *data, /**< Pointer to the data. */
+ size_t size /**< Size of the \a data. */
+ );
+
/** Add a configuration value for an 8-bit SDO.
*
- * \todo doc
+ * \see ecrt_slave_config_sdo().
* \return 0 in case of success, else < 0
*/
int ecrt_slave_config_sdo8(
@@ -555,7 +579,7 @@
/** Add a configuration value for a 16-bit SDO.
*
- * \todo doc
+ * \see ecrt_slave_config_sdo().
* \return 0 in case of success, else < 0
*/
int ecrt_slave_config_sdo16(
@@ -567,7 +591,7 @@
/** Add a configuration value for a 32-bit SDO.
*
- * \todo doc
+ * \see ecrt_slave_config_sdo().
* \return 0 in case of success, else < 0
*/
int ecrt_slave_config_sdo32(
--- a/master/slave_config.c Tue Apr 08 11:52:51 2008 +0000
+++ b/master/slave_config.c Wed Apr 16 08:33:04 2008 +0000
@@ -320,40 +320,6 @@
/*****************************************************************************/
-/** Adds an Sdo configuration.
- */
-int ec_slave_config_sdo(ec_slave_config_t *sc, uint16_t index,
- uint8_t subindex, const uint8_t *data, size_t size)
-{
- ec_slave_t *slave = sc->slave;
- ec_sdo_request_t *req;
-
- if (slave && !(slave->sii.mailbox_protocols & EC_MBOX_COE)) {
- EC_ERR("Slave %u does not support CoE!\n", slave->ring_position);
- return -1;
- }
-
- if (!(req = (ec_sdo_request_t *)
- kmalloc(sizeof(ec_sdo_request_t), GFP_KERNEL))) {
- EC_ERR("Failed to allocate memory for Sdo configuration!\n");
- return -1;
- }
-
- ec_sdo_request_init(req);
- ec_sdo_request_address(req, index, subindex);
-
- if (ec_sdo_request_copy_data(req, data, size)) {
- ec_sdo_request_clear(req);
- kfree(req);
- return -1;
- }
-
- list_add_tail(&req->list, &sc->sdo_configs);
- return 0;
-}
-
-/*****************************************************************************/
-
/** Attaches the configuration to the addressed slave object.
*
* \retval 0 Success.
@@ -677,32 +643,64 @@
/*****************************************************************************/
-int ecrt_slave_config_sdo8(ec_slave_config_t *slave, uint16_t index,
+int ecrt_slave_config_sdo(ec_slave_config_t *sc, uint16_t index,
+ uint8_t subindex, const uint8_t *data, size_t size)
+{
+ ec_slave_t *slave = sc->slave;
+ ec_sdo_request_t *req;
+
+ if (slave && !(slave->sii.mailbox_protocols & EC_MBOX_COE)) {
+ EC_ERR("Slave %u does not support CoE!\n", slave->ring_position);
+ return -1;
+ }
+
+ if (!(req = (ec_sdo_request_t *)
+ kmalloc(sizeof(ec_sdo_request_t), GFP_KERNEL))) {
+ EC_ERR("Failed to allocate memory for Sdo configuration!\n");
+ return -1;
+ }
+
+ ec_sdo_request_init(req);
+ ec_sdo_request_address(req, index, subindex);
+
+ if (ec_sdo_request_copy_data(req, data, size)) {
+ ec_sdo_request_clear(req);
+ kfree(req);
+ return -1;
+ }
+
+ list_add_tail(&req->list, &sc->sdo_configs);
+ return 0;
+}
+
+/*****************************************************************************/
+
+int ecrt_slave_config_sdo8(ec_slave_config_t *sc, uint16_t index,
uint8_t subindex, uint8_t value)
{
uint8_t data[1];
EC_WRITE_U8(data, value);
- return ec_slave_config_sdo(slave, index, subindex, data, 1);
-}
-
-/*****************************************************************************/
-
-int ecrt_slave_config_sdo16(ec_slave_config_t *slave, uint16_t index,
+ return ecrt_slave_config_sdo(sc, index, subindex, data, 1);
+}
+
+/*****************************************************************************/
+
+int ecrt_slave_config_sdo16(ec_slave_config_t *sc, uint16_t index,
uint8_t subindex, uint16_t value)
{
uint8_t data[2];
EC_WRITE_U16(data, value);
- return ec_slave_config_sdo(slave, index, subindex, data, 2);
-}
-
-/*****************************************************************************/
-
-int ecrt_slave_config_sdo32(ec_slave_config_t *slave, uint16_t index,
+ return ecrt_slave_config_sdo(sc, index, subindex, data, 2);
+}
+
+/*****************************************************************************/
+
+int ecrt_slave_config_sdo32(ec_slave_config_t *sc, uint16_t index,
uint8_t subindex, uint32_t value)
{
uint8_t data[4];
EC_WRITE_U32(data, value);
- return ec_slave_config_sdo(slave, index, subindex, data, 4);
+ return ecrt_slave_config_sdo(sc, index, subindex, data, 4);
}
/*****************************************************************************/
@@ -745,6 +743,7 @@
EXPORT_SYMBOL(ecrt_slave_config_pdo_mapping_clear);
EXPORT_SYMBOL(ecrt_slave_config_pdos);
EXPORT_SYMBOL(ecrt_slave_config_reg_pdo_entry);
+EXPORT_SYMBOL(ecrt_slave_config_sdo);
EXPORT_SYMBOL(ecrt_slave_config_sdo8);
EXPORT_SYMBOL(ecrt_slave_config_sdo16);
EXPORT_SYMBOL(ecrt_slave_config_sdo32);