FTDI通用轉USB芯片簡述


FTDI公司的FT2232系列芯片可實現USB與異步串行口RS232/RS485、同步串行總線IIC/SPI/JTAG相互通信,市場占有率,使用普遍。

FTDI芯片有兩種類型的驅動:virtual COM port driver (VCP)和D2xx。VCP就是常用的U轉串COM驅動,實現USB到虛擬串口功能,應用於異步RS232/RS485與USB間通信,linux設備文件為/dev/ttyUSBx;D2XX應用於同步串行總線IIC/SPI/JTAG與USB間通信,整個驅動框架都有FTDI公司提供。

COM驅動

linux支持FTDI公司的VCP驅動需配置內核:

Device Drivers --->

       [*] USB support --->

       <M> USB Serial Converter support --->

                            <M> USB Prolific 2303 Single Port Serial Driver

                            <M> USB FTDI Single Port Serial Driver

Prolific和FTDI是常用的USB轉串口芯片廠商。通用模塊usbserial.ko,prolific公司的模塊pl2303.ko,ftdi公司的模塊ftdi_sio.ko

[    1.771996] usbcore: registered new interface driver usbfs

[    1.777600] usbcore: registered new interface driver hub

[    1.782975] usbcore: registered new device driver usb

[    3.227325] usbcore: registered new interface driver usb-storage

[    3.331190] usbcore: registered new interface driver bcm203x

[    3.336872] usbcore: registered new interface driver bfusb

[    3.342381] usbcore: registered new interface driver btusb

[    3.347893] usbcore: registered new interface driver ath3k

[    3.496381] usbcore: registered new interface driver usbhid

[    3.501958] usbhid: USB HID core driver

[   58.132670] usb 1-1: new full-speed USB device number 2 using xhci-hcd

[   58.314580] usbcore: registered new interface driver usbserial

[   58.316675] usbcore: registered new interface driver pl2303

[   58.316707] usbserial: USB Serial support registered for pl2303

[   58.317386] usb 1-1: pl2303 converter now attached to ttyUSB0

[  289.400405] usb 1-1: USB disconnect, device number 2

[    1.774779] usbcore: registered new interface driver usbfs

[    1.780377] usbcore: registered new interface driver hub

[    1.785752] usbcore: registered new device driver usb

[    3.230535] usbcore: registered new interface driver usb-storage

[    3.334244] usbcore: registered new interface driver bcm203x

[    3.339930] usbcore: registered new interface driver bfusb

[    3.345439] usbcore: registered new interface driver btusb

[    3.350951] usbcore: registered new interface driver ath3k

[    3.495753] usbcore: registered new interface driver usbhid

[    3.501362] usbhid: USB HID core driver

[    3.643788] usb 1-1: new high-speed USB device number 2 using xhci-hcd

[    7.070296] usbcore: registered new interface driver usbserial

[    7.099899] usbcore: registered new interface driver ftdi_sio

[    7.099925] usbserial: USB Serial support registered for FTDI USB Serial Device

[    7.100046] usb 1-1: Detected FT2232H

[    7.100439] usb 1-1: FTDI USB Serial Device converter now attached to ttyUSB0

[    7.100539] usb 1-1: Detected FT2232H

[    7.100667] usb 1-1: FTDI USB Serial Device converter now attached to ttyUSB1

[   86.423288] usb 1-1: USB disconnect, device number 2

插入USB設備會在/dev/ttyUSBx文件出現,可像操作普通的串口文件/dev/ttySx一樣操作,采用通用termios編程。

D2XX驅動

在linux中VCP和D2XX驅動是不兼容的,當D2XX驅動應用前應卸載VCP驅動模塊:

sudo rmmod ftdi_sio

sudo rmmod usbserial

實際測試中采用D2XX驅動時系統會自動卸載VCP驅動。

D2XX驅動協議棧如下圖,D2XX驅動libftd2xx.tar.gz可在如下頁面下載:https://www.ftdichip.com/Drivers/D2XX.htm,或者直接在系統下apt安裝(可能需要libusb-dev):

apt install libftdi-dev

在D2XX驅動之上是libmpsse,即MPSSE庫。Multi Protocol Synchronous Serial Engine(MPSSE)是一個通用的同步總線如I2C、SPI或JTAG通信庫,用於FT2232D、FT2232H、FT4232H和FT232H芯片通過USB與PC或ARM通信。MPSSE基於D2XX設計。

 

D2XX應用

lora gateway就應用了D2XX驅動,將SPI接口轉化為U口與主服務器(X86或ARM)通信,開源庫:https://github.com/yuxi-o/RAK833-LoRaGateway-RPihttps://github.com/Lora-net/lora_gateway.git

 

參考:

1. https://www.ftdichip.com/Support/Documents/AppNotes.htm

2. FTDI FT2232H在嵌入式教學中的應用

3. linux內核支持U-disk和U轉串

4. FTDI Drivers Installation Guide for Linux

5. User Guide For LibMPSSE-SPI


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM