Your browser does not allow scripts
Please click here to view a static table of contents without scripts
SPI_AddDeviceWriteCmd
Return to Introduction  Previous page  Next page
Adds a write command and associated data to the internal command buffer associated with a device. This enables a programmer to build up a sequence of commands i.e. write and read before executing the sequence of commands. The internal command buffer has a size of 131070 bytes (128 kB).

FTC_STATUS
SPI_AddDeviceWriteCmd
(FTC_HANDLE ftHandle, PFTC_INIT_CONDITION pWriteStartCondition, BOOL bClockOutDataBitsMSBFirst, BOOL bClockOutDataBitsPosEdge, DWORD dwNumControlBitsToWrite, PWriteControlByteBuffer pWriteControlBuffer, DWORD dwNumControlBytesToWrite, BOOL bWriteDataBits, DWORD dwNumDataBitsToWrite, PWriteDataByteBuffer pWriteDataBuffer, DWORD dwNumDataBytesToWrite, PFTC_HIGHER_OUTPUT_PINS pHighPinsWriteActiveStates)




Parameters
ftHandle
Handle of the device.
pWriteStartCondition
Pointer to the structure that contains the start output states (low or high) of the clock, data out and signal out/chip select pins of the FT2232C.
bClockOutDataBitsMSBFirst
Clock out control and data bits most significant bit (MSB) first (TRUE), clock out control and data bits least significant bit (LSB) first (FALSE).
bClockOutDataBitsPosEdge
Clock out control and data bits on positive clock edge (TRUE), clock out control and data bits on negative clock edge (FALSE).
dwNumControlBitsToWrite
Specifies the number of control bits to be written to an external device. Valid range 2 to 2040. 2040 bits is equivalent to 255 bytes.
pWriteControlBuffer
Pointer to buffer that contains the control data to be written to an external device. Listed below are three examples of control and address bytes:
Two Control bytes
Control Address byte 1, Control Address byte 2
Two Control bytes, Control Address byte 1, Control Address byte 2
dwNumControlBytesToWrite
Specifies the number of control bytes in the write control buffer, which contains all the specified bits to be written to an external device. Valid range 1 to 255 bytes.
bWriteDataBits
Write data bits to an external device (TRUE), do not write any data bits to an external device (FALSE).
dwNumDataBitsToWrite
Specifies the number of data bits to be written to an external device. Valid range 2 to 524280. 524280 bits is equivalent to 64K bytes.
pWriteDataBuffer
Pointer to buffer that contains the data to be written to an external device.
dwNumDataBytesToWrite
Specifies the number of data bytes in the write data buffer, which contains all the specified bits to be written to an external device. Valid range 1 to 65535 (i.e. 64K bytes).
pHighPinsWriteActiveStates
Pointer to the structure that contains which of the 4 upper general purpose input/output pins of a FT2232C, are to be used during a write to an external device. Each GPIO pin that is to be used during a write to an external device must have been previously configured as an output pin (see SPI_SetGPIOs).




Return Value
FTC_SUCCESS if successful, otherwise the return value is one of the following FTC error codes:

   FTC_INVALID_HANDLE
   FTC_NULL_INITIAL_CONDITION_BUFFER_POINTER
   FTC_INVALID_NUMBER_CONTROL_BITS
   FTC_NULL_WRITE_CONTROL_BUFFER_POINTER
   FTC_INVALID_NUMBER_CONTROL_BYTES
   FTC_NUMBER_CONTROL_BYTES_TOO_SMALL
   FTC_INVALID_NUMBER_DATA_BITS
   FTC_NULL_WRITE_DATA_BUFFER_POINTER
   FTC_INVALID_NUMBER_DATA_BYTES
   FTC_NUMBER_DATA_BYTES_TOO_SMALL
   FTC_INVALID_FT2232C_DATA_WRITE_COMPLETE_PIN
   FTC_NULL_OUTPUT_PINS_BUFFER_POINTER
   FTC_INVALID_INIT_CLOCK_PIN_STATE
   FTC_INVALID_FT2232C_CHIP_SELECT_PIN
   FTC_DATA_WRITE_COMPLETE_TIMEOUT
   FTC_INVALID_FT2232C_DATA_WRITE_COMPLETE_PIN
   FTC_INVALID_CONFIGURATION_HIGHER_GPIO_PIN
   FTC_COMMAND_SEQUENCE_BUFFER_FULL


Remarks
Do not invoke SPI_Write or SPI_Read functions while constructing a sequence of commands as this will clear the sequence of commands and associated data from the internal command buffer.

This command can be used with multiple devices connected.

Calling this function is equivalent to adding the commands and data from a
SPI_Write call to the internal command buffer.

This function can be used with
SPI_ClearDeviceCmdSequence, SPI_AddDeviceReadCmd and SPI_ExecuteCmdSequence to buffer a long list of commands and data which can then be sent to the FT2232C in one go. This can provide faster data transfer rates in some applications.

The write start condition, write control buffer, write data buffer, wait data write complete and high pins write active states definitions are given in the
Appendix.