AN_111_Programmers_Guide_for_High_Speed_FTCSPI_DLL.pdf

(411 KB) Pobierz
Microsoft Word - AN_111_Programmers_Guide_for_High_Speed_FTCSPI_DLL
Future Technology Devices International Ltd.
Application Note AN_111
Programmers Guide for High Speed
FTCSPI DLL
Document Reference No.: FT_000112
Version 1.1
Issue Date: 2009-03-18
This document provides details of the function calls required when using the High Speed
FTCSPI dll.
Future Technology Devices International Limited (FTDI)
Unit1, 2 Seaward Place, Centurion Business Park, Glasgow G41 1HH United Kingdom
Tel.: +44 (0) 141 429 2777 Fax: + 44 (0) 141 429 2758
E-Mail (Support): support1@ftdichip.com Web: http://www.ftdichip.com
Copyright ¨ 2009 Future Technology Devices International Limited
721517259.010.png
Document Reference No.: FT_000112
Programmers Guide for High Speed FTCSPI DLL Application Note AN_111
Version 1.1
Clearance No.: FTDI# 84
TABLE OF CONTENTS
1
Introduction............................................................................................ 3
2
Application Programming Interface (API) ............................................ 4
2.1
Public Functions .................................................................................................. 4
2.1.1
SPI_GetNumDevices............................................................................................................... 4
2.1.2
SPI_GetNumHiSpeedDevices................................................................................................. 4
2.1.3
SPI_GetDeviceNameLocID ..................................................................................................... 5
2.1.4
SPI_GetHiSpeedDeviceNameLocIDChannel.......................................................................... 6
2.1.5
SPI_Open ................................................................................................................................ 7
2.1.6
SPI_OpenEx ............................................................................................................................ 8
2.1.7
SPI_OpenHiSpeedDevice ....................................................................................................... 9
2.1.8
SPI_GetHiSpeedDeviceType ................................................................................................ 10
2.1.9
SPI_Close.............................................................................................................................. 11
2.1.10
SPI_CloseDevice................................................................................................................... 11
2.1.11
SPI_InitDevice ....................................................................................................................... 11
2.1.12
SPI_TurnOnDivideByFiveClockingHiSpeedDevice............................................................... 12
2.1.13
SPI_TurnOffDivideByFiveClockingHiSpeedDevice............................................................... 13
2.1.14
SPI_SetDeviceLatencyTimer................................................................................................. 14
2.1.15
SPI_GetDeviceLatencyTimer ................................................................................................ 14
2.1.16
SPI_GetClock ........................................................................................................................ 15
2.1.17
SPI_GetHiSpeedDeviceClock ............................................................................................... 15
2.1.18
SPI_SetClock......................................................................................................................... 17
2.1.19
SPI_SetLoopback .................................................................................................................. 18
2.1.20
SPI_SetGPIOs....................................................................................................................... 19
2.1.21
SPI_SetHiSpeedDeviceGPIOs.............................................................................................. 21
2.1.22
SPI_GetGPIOs ...................................................................................................................... 23
2.1.23
SPI_GetHiSpeedDeviceGPIOs ............................................................................................. 24
2.1.24
SPI_Write............................................................................................................................... 25
2.1.25
SPI_WriteHiSpeedDevice...................................................................................................... 29
2.1.26
SPI_Read .............................................................................................................................. 33
2.1.27
SPI_ReadHiSpeedDevice ..................................................................................................... 37
2.1.28
SPI_ClearDeviceCmdSequence ........................................................................................... 41
2.1.29
SPI_AddDeviceWriteCmd ..................................................................................................... 42
2.1.30
SPI_AddHiSpeedDeviceWriteCmd........................................................................................ 45
2.1.31
SPI_AddDeviceReadCmd ..................................................................................................... 49
2.1.32
SPI_AddHiSpeedDeviceReadCmd ....................................................................................... 52
2.1.33
SPI_ExecuteDeviceCmdSequence ....................................................................................... 56
2.1.34
SPI_GetDllVersion................................................................................................................. 57
2.1.35
SPI_GetErrorCodeString ....................................................................................................... 57
Copyright ¨ 2009 Future Technology Devices International Limited
1
721517259.011.png 721517259.012.png 721517259.013.png
Document Reference No.: FT_000112
Programmers Guide for High Speed FTCSPI DLL Application Note AN_111
Version 1.1
Clearance No.: FTDI# 84
3 FTCSPI.h .............................................................................................. 58
4 Contact Information............................................................................. 66
Appendix A Î Revision History ................................................................. 68
Copyright ¨ 2009 Future Technology Devices International Limited
2
721517259.001.png 721517259.002.png 721517259.003.png
Document Reference No.: FT_000112
Programmers Guide for High Speed FTCSPI DLL Application Note AN_111
Version 1.1
Clearance No.: FTDI# 84
1 Introduction
The FT2232D, FT2232H and FT4232H devices contains FTDI's multi-protocol synchronous serial engine
(MPSSE) controller, which may be used to interface to many popular synchronous serial protocols
including JTAG, SPI and I2C.
The FT2232 SPI API will provide a set of function's to allow a programmer to control the FT2232D dual
device MPSSE controller, the FT2232H dual device MPSSE hi-speed controller and the FT4232H quad
device MPSSE hi-speed controller, to communicate with other devices using the Serial Peripheral
Interface(SPI) synchronous serial protocol interface. The FT2232 SPI API will be contained within the
FTCSPI.DLL . The FT2232D dual device can communicate with up to a maximum of 5 SPI devices. This is
achieved because the FTCSPI.DLL supports 5 chip select pins on the FT2232D dual device.
The FTCSPI DLL has been created to allow application developers to use the FT2232D, FT2232H and
FT4232H devices to create a USB to Serial Peripheral Interface (SPI) protocol interface without any
knowledge of the MPSSE command set. All of the functions in FTCSPI.DLL can be replicated using calls to
FTD2XX.DLL and sending the appropriate commands to the MPSSE.
The FT2232D MPSSE controller is only available through channel A of the FT2232D device; channel B of
the FT2232D device does not support the MPSSE. Channel B may be controlled independently using
FTDI's FTCD2XX drivers while channel A is being used for SPI communication.
The FT2232H MPSSE controller is available through channels A and B of the FT2232H device; both
channels A and B can be used for SPI communication.
The FT4232H MPSSE controller is only available through channels A and B of the FT4232H device;
channels C and D of the FT4232H device do not support the MPSSE. Channels C and D may be controlled
independently using FTDI's FTCD2XX drivers while channels A and B are being used for SPI
communication.
This document lists all of the functions available in FTCSPI.DLL.
Copyright ¨ 2009 Future Technology Devices International Limited
3
721517259.004.png 721517259.005.png 721517259.006.png
Document Reference No.: FT_000112
Programmers Guide for High Speed FTCSPI DLL Application Note AN_111
Version 1.1
Clearance No.: FTDI# 84
2 Application Programming Interface (API)
2.1 Public Functions
2.1.1 SPI_GetNumDevices
FTC_STATUS SPI_GetNumDevices(LPDWORD lpdwNumDevices)
This function must be used, if more than one FT2232D dual device will be connected to a system. This
function returns the number of available FT2232D dual device(s) connected to a system.
Parameters
lpdwNumDevices
Pointer to a variable of type DWORD which receives the actual
number of available FT2232D dual device(s) connected to a
system.
Return Value
Returns FTC_SUCCESS if successful, otherwise the return value will be one of the following error
codes:
FTC_IO_ERROR
2.1.2 SPI_GetNumHiSpeedDevices
FTC_STATUS SPI_GetNumHiSpeedDevices(LPDWORD lpdwTotalNumHiSpeedDevices)
This function must be used, if more than one FT2232H dual/FT4232H quad hi-speed devices will be
connected to a system. This function returns the number of available FT2232H dual and FT4232H
quad hi-speed device(s) connected to a system.
Parameters
lpdwTotalNumHiSpeedDevices
Pointer to a variable of type DWORD which receives the
total number of available FT2232H dual and FT4232H
quad hi-speed device(s) connected to a system.
Return Value
Returns FTC_SUCCESS if successful, otherwise the return value will be one of the following error
codes:
FTC_IO_ERROR
Copyright ¨ 2009 Future Technology Devices International Limited
4
721517259.007.png 721517259.008.png 721517259.009.png
Zgłoś jeśli naruszono regulamin