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 --->

        USB Serial Converter support --->

                             USB Prolific 2303 Single Port Serial Driver

                             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设计。

 FTDI通用转USB芯片简述_第1张图片FTDI通用转USB芯片简述_第2张图片

D2XX应用

lora gateway就应用了D2XX驱动,将SPI接口转化为U口与主服务器(X86或ARM)通信,开源库:https://github.com/yuxi-o/RAK833-LoRaGateway-RPi或https://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

转载于:https://www.cnblogs.com/embedded-linux/p/10345947.html

你可能感兴趣的:(FTDI通用转USB芯片简述)