It's possible to sample the value on hostmot2 physical I/O pins even
when they are used as outputs--either gpio or special-purpose modules
like stepgen.

Use 1 (most useful): For an open-drain output, the pin can be driven
low by an external source.  This allows a sort of one-wire handshake.

Use 2: You can read the output of a special purpose module.
Reading the output of a special-purpose module probably has limited
usefulness--since it samples at a very low rate, you can't see the true
step+direction waveform, just like sampling a software stepgen's step
pin in the servo-thread of a system where it runs on the base-thread
gives misleading results.

But it might be useful in a few special circumstances; for instance, by
properly setting the step timings it might be possible to guarantee
catching every output transition, and this could be used in some kind of
testing.

Use 3 (least useful): For the sake of consistency, a gpio "in" pin now
tracks the corresponding "out" pin, for push-pull outputs.

Jeff

Index: ioport.c
===================================================================
RCS file: /cvs/emc2/src/hal/drivers/mesa-hostmot2/ioport.c,v
retrieving revision 1.11
diff -u -p -r1.11 ioport.c
--- ioport.c    21 Feb 2009 01:53:07 -0000      1.11
+++ ioport.c    4 Jun 2009 22:11:18 -0000
@@ -217,40 +217,35 @@ int hm2_ioport_gpio_export_hal(hostmot2_
 
 
         //
-        // it's a full GPIO or it's an input for some other module
+        // all pins' values can be read; for pins used as outputs
+        // (including special-purpose outputs), the output value is sampled.
         //
 
-        if (
-            (hm2->pin[i].gtag == HM2_GTAG_IOPORT)
-            || (hm2->pin[i].direction == HM2_PIN_DIR_IS_INPUT)
-        ) {
-
-            // pins
-            r = hal_pin_bit_newf(
-                HAL_OUT,
-                &(hm2->pin[i].instance->hal.pin.in),
-                hm2->llio->comp_id,
-                "%s.gpio.%03d.in",
-                hm2->llio->name,
-                i
-            );
-            if (r != HAL_SUCCESS) {
-                HM2_ERR("error %d adding gpio pin, aborting\n", r);
-                return -EINVAL;
-            }
-
-            r = hal_pin_bit_newf(
-                HAL_OUT,
-                &(hm2->pin[i].instance->hal.pin.in_not),
-                hm2->llio->comp_id,
-                "%s.gpio.%03d.in_not",
-                hm2->llio->name,
-                i
-            );
-            if (r != HAL_SUCCESS) {
-                HM2_ERR("error %d adding gpio pin, aborting\n", r);
-                return -EINVAL;
-            }
+        // pins
+        r = hal_pin_bit_newf(
+            HAL_OUT,
+            &(hm2->pin[i].instance->hal.pin.in),
+            hm2->llio->comp_id,
+            "%s.gpio.%03d.in",
+            hm2->llio->name,
+            i
+        );
+        if (r != HAL_SUCCESS) {
+            HM2_ERR("error %d adding gpio pin, aborting\n", r);
+            return -EINVAL;
+        }
+
+        r = hal_pin_bit_newf(
+            HAL_OUT,
+            &(hm2->pin[i].instance->hal.pin.in_not),
+            hm2->llio->comp_id,
+            "%s.gpio.%03d.in_not",
+            hm2->llio->name,
+            i
+        );
+        if (r != HAL_SUCCESS) {
+            HM2_ERR("error %d adding gpio pin, aborting\n", r);
+            return -EINVAL;
         }
 
 
@@ -502,8 +497,6 @@ void hm2_ioport_gpio_process_tram_read(h
             int io_pin = (port * hm2->idrom.port_width) + port_pin;
             hal_bit_t bit;
 
-            if (hm2->pin[io_pin].direction != HM2_PIN_DIR_IS_INPUT) continue;
-
             bit = (hm2->ioport.data_read_reg[port] >> port_pin) & 0x1;
             *hm2->pin[io_pin].instance->hal.pin.in = bit;
             *hm2->pin[io_pin].instance->hal.pin.in_not = !bit;

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to