All pastes #845225 Raw Edit

Unnamed

public text v1 · immutable
#845225 ·published 2008-01-07 15:20 UTC
rendered paste body
--- hal/drivers/hal_parport.old.c	2008-01-07 09:51:58.000000000 -0500
+++ hal/drivers/hal_parport.c	2008-01-07 10:17:27.000000000 -0500
@@ -511,8 +511,8 @@
 static void read_port(void *arg, long period)
 {
     parport_t *port;
-    int b;
-    unsigned char indata, mask;
+    register hal_bit_t **b,**c;
+    register unsigned char indata, mask;
 
     port = arg;
     /* read the status port */
@@ -521,33 +521,66 @@
     indata ^= 0x80;
     /* split the bits into 10 variables (5 regular, 5 inverted) */
     mask = 0x08;
-    for (b = 0; b < 10; b += 2) {
+    b=port->status_in;
+    c=b+40;
+    /*for (b = 0; b < 10; b += 2) {
 	*(port->status_in[b]) = indata & mask;
 	*(port->status_in[b + 1]) = !(indata & mask);
 	mask <<= 1;
+    }*/
+    while (b<c)
+    {
+    	*(*(b))=indata & mask;
+	    b+=4;
+    	*(*(b))=!(indata & mask);
+    	b+=4;
+    	mask<<=1;
     }
+    
     /* are we using the data port for input? */
     if (port->data_dir != 0) {
 	/* yes, read the data port */
 	indata = rtapi_inb(port->base_addr);
 	/* split the bits into 16 variables (8 regular, 8 inverted) */
 	mask = 0x01;
-	for (b = 0; b < 16; b += 2) {
+	b=port->data_in;
+    c=b+64;
+	/*for (b = 0; b < 16; b += 2) {
 	    *(port->data_in[b]) = indata & mask;
 	    *(port->data_in[b + 1]) = !(indata & mask);
 	    mask <<= 1;
+	}*/
+	while (b<c)
+	{
+	    *(*(b))=indata & mask;
+	    b+=4;
+    	*(*(b))=!(indata & mask);
+    	b+=4;
+    	mask<<=1;
 	}
+	
     }
     /* are we using the control port for input? */
     if(port->use_control_in) {
         mask = 0x01;
         /* correct for hardware inverters on pins 1, 14, & 17 */
         indata = rtapi_inb(port->base_addr + 2) ^ 0x0B;
-        for (b = 0; b < 8; b += 2) {
+        b=port->control_in;
+        c=b+32;
+        /*for (b = 0; b < 8; b += 2) {
             *(port->control_in[b]) = indata & mask;
             *(port->control_in[b + 1]) = !(indata & mask);
 	    mask <<= 1;
+        }*/
+        while (b<c)
+        {
+        	*(*(b))=indata & mask;
+			b+=4;
+			*(*(b))=!(indata & mask);
+			b+=4;
+			mask<<=1;
         }
+        
     }
 }