Introduced EC_MAP_END.
authorFlorian Pose <fp@igh-essen.com>
Mon, 31 Mar 2008 09:42:37 +0000
changeset 878 40c379697ebf
parent 877 d2915690047f
child 879 9b395c5646ab
Introduced EC_MAP_END.
examples/mini/mini.c
include/ecrt.h
master/slave_config.c
--- a/examples/mini/mini.c	Wed Mar 19 10:51:18 2008 +0000
+++ b/examples/mini/mini.c	Mon Mar 31 09:42:37 2008 +0000
@@ -96,6 +96,7 @@
 static ec_pdo_info_t el3162_mapping[] = {
     {EC_DIR_INPUT, 0x1A00, 2, el3162_channel1},
     {EC_DIR_INPUT, 0x1A01, 2, el3162_channel2},
+    {EC_MAP_END}
 };
 
 static ec_pdo_entry_info_t el2004_channels[] = {
@@ -279,7 +280,7 @@
         goto out_release_master;
     }
 
-    if (ecrt_slave_config_mapping(sc, 2, el3162_mapping)) {
+    if (ecrt_slave_config_mapping(sc, EC_MAP_END, el3162_mapping)) {
         printk(KERN_ERR PFX "Failed to configure Pdo mapping.\n");
         goto out_release_master;
     }
--- a/include/ecrt.h	Wed Mar 19 10:51:18 2008 +0000
+++ b/include/ecrt.h	Mon Mar 31 09:42:37 2008 +0000
@@ -120,6 +120,14 @@
  */
 #define ECRT_VERSION_MAGIC ECRT_VERSION(ECRT_VER_MAJOR, ECRT_VER_MINOR)
 
+/*****************************************************************************/
+
+/** End of mapping.
+ *
+ * This is used in ecrt_slave_config_mapping().
+ */
+#define EC_MAP_END ~0U
+
 /******************************************************************************
  * Data types 
  *****************************************************************************/
@@ -467,6 +475,12 @@
  *     return -1; // error
  * \endcode
  *
+ * Processing of \a pdo_infos will stop, if
+ * - the number of processed items reaches \a n_infos, or
+ * - the \a dir member of an ec_pdo_info_t item is EC_MAP_END. In this case,
+ *   \a n_infos should set to a number greater than the number of list items;
+ *   using EC_MAP_END is recommended.
+ *
  * \return zero on success, else non-zero
  */
 int ecrt_slave_config_mapping(
--- a/master/slave_config.c	Wed Mar 19 10:51:18 2008 +0000
+++ b/master/slave_config.c	Mon Mar 31 09:42:37 2008 +0000
@@ -582,6 +582,10 @@
 
     for (i = 0; i < n_infos; i++) {
         pi = &pdo_infos[i];
+
+        if (pi->dir == EC_MAP_END)
+            break;
+
         pm = &sc->mapping[pi->dir];
 
         if (pm->default_mapping) {