FTC_STATUS
|
SPI_Write
|
(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_WAIT_DATA_WRITE pWaitDataWriteComplete, 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).
|
pWaitDataWriteComplete
|
Pointer to the structure that contains data that controls whether the FT2232C should wait until all data bytes have been written to an external device before returning.
|
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_WRITE_DATA_BITS
FTC_NULL_WRITE_DATA_BUFFER_POINTER
FTC_INVALID_NUMBER_WRITE_DATA_BYTES
FTC_NUMBER_WRITE_DATA_BYTES_TOO_SMALL
FTC_NULL_WAIT_DATA_WRITE_BUFFER_POINTER
FTC_NULL_OUTPUT_PINS_BUFFER_POINTER
FTC_INVALID_INIT_CLOCK_PIN_STATE
FTC_INVALID_FT2232C_CHIP_SELECT_PIN
FTC_INVALID_FT2232C_DATA_WRITE_COMPLETE_PIN
FTC_DATA_WRITE_COMPLETE_TIMEOUT
FTC_INVALID_CONFIGURATION_HIGHER_GPIO_PIN
FTC_FAILED_TO_COMPLETE_COMMAND
FTC_IO_ERROR
Remarks
This function will write data from the FT2232C to an external device using the SPI protocol. The data will be clocked at a rate specified by the clock divisor set by calling either the SPI_InitDevice or SPI_SetClock functions.
The init condition, write control buffer, write data buffer, wait data write complete and high pins write active states definitions are given in the Appendix.
Example
#define NUM_93LC56B_CMD_CONTOL_BITS 11
#define NUM_93LC56B_CMD_CONTOL_BYTES 2
const SPI_EWEN_CMD = '\x9F'; // set up write enable command
FTC_STATUS Status = FTC_SUCCESS;
FTC_HANDLE ftHandle;
FTC_INIT_CONDITION WriteStartCondition;
WriteControlByteBuffer WriteControlBuffer;
WriteDataByteBuffer WriteDataBuffer;
FTC_WAIT_DATA_WRITE WaitDataWriteComplete;
FTC_HIGHER_OUTPUT_PINS HighPinsWriteActiveStates;
WriteStartCondition.bClockPinState = false;
WriteStartCondition.bDataOutPinState = false;
WriteStartCondition.bChipSelectPinState = false;
WriteStartCondition.dwChipSelectPin = ADBUS3ChipSelect;
WaitDataWriteComplete.bWaitDataWriteComplete = false;
HighPinsWriteActiveStates.bPin1ActiveState = false;
HighPinsWriteActiveStates.bPin1State = false;
HighPinsWriteActiveStates.bPin2ActiveState = false;
HighPinsWriteActiveStates.bPin2State = false;
HighPinsWriteActiveStates.bPin3ActiveState = false;
HighPinsWriteActiveStates.bPin3State = false;
HighPinsWriteActiveStates.bPin4ActiveState = false;
HighPinsWriteActiveStates.bPin4State = false;
// enable writing
WriteControlBuffer[0] = SPI_EWEN_CMD;
WriteControlBuffer[1] = '\xFF';
Status = SPI_Write(ftHandle, &WriteStartCondition, true, false, NUM_93LC56B_CMD_CONTOL_BITS, &WriteControlBuffer, NUM_93LC56B_CMD_CONTOL_BYTES, false, 0, &WriteDataBuffer, 0, &WaitDataWriteComplete, &HighPinsWriteActiveStates);