MVoz / libmpsse

Automatically exported from code.google.com/p/libmpsse
0 stars 0 forks source link

SPI transfer with +1024 bytes size #22

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. SPI transfer with + 1024 bytes

What is the expected output? What do you see instead?
Its blocking... I expect a result :-)

What version of the product are you using? On what operating system?
libmpsse-1.2-1
Linux lars-pc 3.5.0-22-generic #34-Ubuntu SMP Tue Jan 8 21:47:00 UTC 2013 
x86_64 x86_64 x86_64 GNU/Linux

Please provide any additional information below.
There is a bug inside the Transfer function.
Also I had to decrease the SPI_TRANSFER_SIZE.

diff --git a/spi/mpsse.c b/spi/mpsse.c
index 8347b0b..dca3cee 100644
@@ -767,14 +767,14 @@ char *Transfer(struct mpsse_context *mpsse, char *data, 
int size)
                memset(buf, 0, size);

                /* When sending and recieving, FTDI chips don't seem to like large data blocks. Limit the size of each block to SPI_TRANSFER_SIZE */
-               rxsize = size - n;
-               if(rxsize > SPI_TRANSFER_SIZE)
-               {
-                   rxsize = SPI_TRANSFER_SIZE;
-               }

                while(n < size)
                {
+                   rxsize = size - n;
+                   if(rxsize > SPI_TRANSFER_SIZE)
+                   {
+                       rxsize = SPI_TRANSFER_SIZE;
+                   }
                    txdata = build_block_buffer(mpsse, mpsse->txrx, (unsigned char *) (data + n), rxsize, &data_size);
                    if(txdata)
                    {
diff --git a/spi/mpsse.h b/spi/mpsse.h
index cc6da43..1c8234f 100644
@@ -12,7 +12,7 @@

 #define CHUNK_SIZE     65535
 #define SPI_RW_SIZE        (63 * 1024) 
-#define SPI_TRANSFER_SIZE  1024
+#define SPI_TRANSFER_SIZE  512
 #define I2C_TRANSFER_SIZE  64

 #define LATENCY_MS     2

Original issue reported on code.google.com by webla...@googlemail.com on 2 Feb 2013 at 10:34

GoogleCodeExporter commented 9 years ago
Patch applied, thanks!

Original comment by heffne...@gmail.com on 3 Feb 2013 at 4:13