FTDI Community

General Category => Discussion - Drivers => Topic started by: hungnung.yang on March 27, 2023, 09:54:49 AM

Title: libMPSSE V1.0.3 SPI_Write
Post by: hungnung.yang on March 27, 2023, 09:54:49 AM
Hi,
I have a question about the SPI_Write in ftdi_spi.c:

from line558~577
Code: [Select]

      while(*sizeTransferred < sizeToTransfer)
      {

         CurrentXferSize = ((sizeToTransfer - *sizeTransferred) > 64*1024)? 64*1024:(sizeToTransfer - *sizeTransferred);
         /* length low byte */
         cmdBuffer[1] = (uint8)((CurrentXferSize-1) & 0x000000FF);
         /* length high byte */
         cmdBuffer[2] = (uint8)(((CurrentXferSize-1) & 0x0000FF00)>>8;
         /* write command */
         status = FT_Channel_Write(SPI, handle, 3, cmdBuffer,\
            &noOfBytesTransferred);
         CHECK_STATUS(status);
         /* write data */
         status = FT_Channel_Write(SPI, handle, CurrentXferSize, buffer,\
            &noOfBytesTransferred);
         *sizeTransferred += noOfBytesTransferred;
         
         CHECK_STATUS(status);
         
      }


Why send buffer only
Code: [Select]

/* write data */
         status = FT_Channel_Write(SPI, handle, CurrentXferSize, buffer,\
            &noOfBytesTransferred);

 
should change to (buffer + *sizeTransferred)?
Code: [Select]

/* write data */
         status = FT_Channel_Write(SPI, handle, CurrentXferSize, (buffer + *sizeTransferred),\
            &noOfBytesTransferred);



Thanks

Title: Re: libMPSSE V1.0.3 SPI_Write
Post by: FTDI Community on April 27, 2023, 04:52:42 PM
Hi,
Our LibMPSSE source code is provided on the FTDI website if you want to make changes.
https://ftdichip.com/software-examples/mpsse-projects/ (https://ftdichip.com/software-examples/mpsse-projects/)

You could also choose not to use LibMPSSE and use d2xx direct. (See AN_108)
https://ftdichip.com/wp-content/uploads/2020/08/AN_108_Command_Processor_for_MPSSE_and_MCU_Host_Bus_Emulation_Modes.pdf (https://ftdichip.com/wp-content/uploads/2020/08/AN_108_Command_Processor_for_MPSSE_and_MCU_Host_Bus_Emulation_Modes.pdf)

Regards
FTDI Community