Change gpio-read-string and gpio-write-string to take position and
authorGuillermo J. Rozas <edu/mit/csail/zurich/gjr>
Mon, 25 Jun 1990 18:33:46 +0000 (18:33 +0000)
committerGuillermo J. Rozas <edu/mit/csail/zurich/gjr>
Mon, 25 Jun 1990 18:33:46 +0000 (18:33 +0000)
count parameters, rather than just count parameters.  This speeds up
output when it is divided into chunks.

v7/src/microcode/gpio.c

index 56214beb0c56cc0810f18b44384e36e690d4658d..c0af32cc425baba38fdba5adb12659e38b1fe339 100644 (file)
@@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising,
 promotional, or sales literature without prior written consent from
 MIT in each case. */
 
-/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/gpio.c,v 1.3 1990/06/13 21:15:14 jinx Exp $ */
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/gpio.c,v 1.4 1990/06/25 18:33:46 jinx Exp $ */
 
 /* Scheme primitives for GPIO */
 
@@ -41,89 +41,6 @@ MIT in each case. */
 #include <fcntl.h> 
 #include <dvio.h>
 \f
-/* "Old style" primitives.
-   Should be flushed.
- */
-
-DEFINE_PRIMITIVE ("OPEN-GPIO", Prim_open_gpio, 1, 1, 0)
-{
-  int gpio_channel;
-
-  PRIMITIVE_HEADER (1);
-
-  gpio_channel = open (STRING_ARG (1), O_RDWR);
-  if (gpio_channel == -1) error_external_return();    
-
-  io_reset (gpio_channel);
-  io_width_ctl (gpio_channel, 16);
-  
-  PRIMITIVE_RETURN( long_to_integer (gpio_channel));
-}
-
-
-DEFINE_PRIMITIVE ("CLOSE-GPIO", Prim_close_gpio, 1, 1, 0)
-{
-  int gpio_channel;
-
-  PRIMITIVE_HEADER (1);
-
-  gpio_channel = (arg_integer (1));
-  close ( gpio_channel );
-  
-  PRIMITIVE_RETURN( long_to_integer( gpio_channel ));
-}
-
-
-DEFINE_PRIMITIVE ("READ-GPIO", Prim_read_gpio, 1, 1, 0)
-{
-  int gpio_channel;
-  unsigned long result;
-  unsigned char buffer[4];
-  int xfer;
-
-  PRIMITIVE_HEADER (1);
-
-  gpio_channel = arg_integer(1);
-
-  buffer[0] = ((unsigned char) 0);
-  buffer[1] = ((unsigned char) 0);
-
-  xfer = read (gpio_channel, &buffer[0], 2);
-
-  if (xfer != 2) error_external_return();
-
-  result = ((unsigned long) buffer[1]);
-  result = (result + (((unsigned long) buffer[0]) << 8));
-
-  PRIMITIVE_RETURN( long_to_integer (result));
-}
-
-
-DEFINE_PRIMITIVE ("WRITE-GPIO", Prim_write_gpio, 2, 2, 0)
-{
-  int gpio_channel;
-  unsigned long output;
-  unsigned char buffer[2];
-  int xfer;
-
-  PRIMITIVE_HEADER (2);
-
-  gpio_channel = (arg_integer (1));
-  output = (arg_integer (2));
-
-  buffer[1] = (output & 0xff);
-  buffer[0] = ((output >> 8) & 0xff);
-
-  xfer = write (gpio_channel, &buffer[0], 2);
-
-  /* xfer is 2 if successfull */
-  PRIMITIVE_RETURN( long_to_integer( xfer ));
-}
-\f
-/* "New style" primitives. */
-
-
 DEFINE_PRIMITIVE ("GPIO-OPEN", Prim_gpio_open, 1, 1, 0)
 {
   int gpio_channel;
@@ -194,35 +111,37 @@ DEFINE_PRIMITIVE ("GPIO-WRITE-CONTROL", Prim_gpio_write_control, 2, 2, 0)
 /* Both of the following return the number of bytes transferred. */
 
 
-DEFINE_PRIMITIVE ("GPIO-READ-STRING!", Prim_gpio_read_string, 3, 3, 0)
+DEFINE_PRIMITIVE ("GPIO-READ-STRING!", Prim_gpio_read_string, 4, 4, 0)
 {
-  int gpio_channel, count, result;
+  int gpio_channel, position, count, result;
   char *data;
 
-  PRIMITIVE_HEADER (3);
+  PRIMITIVE_HEADER (4);
 
   gpio_channel = (UNSIGNED_FIXNUM_ARG (1));
   data = (STRING_ARG (2));
-  count = (UNSIGNED_FIXNUM_ARG (3));
+  position = (UNSIGNED_FIXNUM_ARG (3));
+  count = (UNSIGNED_FIXNUM_ARG (4));
 
-  result = (read (gpio_channel, &data[0], count));
+  result = (read (gpio_channel, &data[position], count));
 
   PRIMITIVE_RETURN( LONG_TO_FIXNUM (result));
 }
 
 
-DEFINE_PRIMITIVE ("GPIO-WRITE-STRING", Prim_gpio_write_string, 3, 3, 0)
+DEFINE_PRIMITIVE ("GPIO-WRITE-STRING", Prim_gpio_write_string, 4, 4, 0)
 {
-  int gpio_channel, count, result;
+  int gpio_channel, position, count, result;
   char *data;
 
-  PRIMITIVE_HEADER (3);
+  PRIMITIVE_HEADER (4);
 
   gpio_channel = (UNSIGNED_FIXNUM_ARG (1));
   data = (STRING_ARG (2));
-  count = (UNSIGNED_FIXNUM_ARG (3));
+  position = (UNSIGNED_FIXNUM_ARG (3));
+  count = (UNSIGNED_FIXNUM_ARG (4));
 
-  result = (write (gpio_channel, &data[0], count));
+  result = (write (gpio_channel, &data[position], count));
 
   PRIMITIVE_RETURN( LONG_TO_FIXNUM ( result ));
 }