最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【记录】尝试找到FTDI的USB转串口芯片FT232R中关于流控制的寄存器(FTDI_SIO_SET_FLOW_CTRL或SIO_SET_FLOW_CTRL)的位定义

USB crifan 4518浏览 0评论

【背景】

之前折腾,需要实现,Android平台上的,FTDI的USB转串口的驱动。

已经参考:

usb-serial-for-android

然后得知,其已经实现了,针对于CDC ACM的USB转串口驱动。

而对于另外一款芯片:FTDI的USB转串口的驱动,没有实现对应的setRts的函数。

所以,后来是参考了:

libFTDI – FTDI USB driver with bitbang mode

中的:

libftdi1-1.0.tar\libftdi1-1.0\libftdi1-1.0\src\ftdi.h
libftdi1-1.0.tar\libftdi1-1.0\libftdi1-1.0\src\ftdi.c

去实现了,android平台的,usb转串口的驱动。

已经验证可以工作了。

但是,现在,看到驱动中,对应的寄存器方面的定义:

/* Definitions for flow control */
#define SIO_RESET          0 /* Reset the port */
#define SIO_MODEM_CTRL     1 /* Set the modem control register */
#define SIO_SET_FLOW_CTRL  2 /* Set flow control register */
#define SIO_SET_BAUD_RATE  3 /* Set baud rate */
#define SIO_SET_DATA       4 /* Set the data characteristics of the port */

对于这些寄存器,虽然已经可以从各种资料中,找到具体的,每个位的确切含义。

但是,还是想要找到,原始的,ftdi的datasheet,想要确认一下。

因为,万一找不到类似的代码,如果需要自己写此驱动,那么还是需要对应的datasheet的。

 

注:

1.关于FT232R的datasheet,其实之前就找到了:

FT232R Datasheet

但是很明显,其中没有此处所需要的,对应的flow control的寄存器的位域的定义。

2.关于FT232R,这里有官方介绍:

FT232R – Single USB 2.0 to Serial UART Converter IC.

3.对应的相关的定义,也可以直接在线查看到:

#define SIO_SET_FLOW_CTRL   2 /* Set flow control register */

 

【解决过程】

1.找到:

FTDI_Constants.java

很明显,其中也有类似的定义:

	/* Pre-defined Requests:  */	
	public static final int SIO_RESET_REQUEST				=0x00;
	public static final int SIO_SET_MODEM_CTRL_REQUEST		=0x01;
	public static final int SIO_SET_FLOW_CTRL_REQUEST		=0x02;
	public static final int SIO_SET_BAUDRATE_REQUEST		=0x03;
	public static final int SIO_SET_DATA_REQUEST			=0x04;	
	public static final int SIO_POLL_MODEM_STATUS_REQUEST	=0x05;
	public static final int SIO_SET_EVENT_CHAR_REQUEST		=0x06;
	public static final int SIO_SET_ERROR_CHAR_REQUEST		=0x07;
	public static final int SIO_SET_LATENCY_TIMER_REQUEST	=0x09;
	public static final int SIO_GET_LATENCY_TIMER_REQUEST	=0x0A;
	public static final int SIO_SET_BITMODE_REQUEST			=0x0B;
	public static final int SIO_READ_PINS_REQUEST			=0x0C;
	public static final int SIO_READ_EEPROM_REQUEST			=0x90;
	public static final int SIO_WRITE_EEPROM_REQUEST		=0x91;
	public static final int SIO_ERASE_EEPROM_REQUEST		=0x92;
    
	
	//Note: these are used together with SIO_SET_FLOW_CTRL_REQUEST.
	//flow control setting is a little special, the following values are actually sent in "Index"
	//while higher byte is flow control, lower byte is chip channel index (channel A, B, C or D)
	public static final int SIO_DISABLE_FLOW_CTRL	=0x0;
	public static final int SIO_RTS_CTS_HS			=(0x1 << 8);
	public static final int SIO_DTR_DSR_HS			=(0x2 << 8);
	public static final int SIO_XON_XOFF_HS			=(0x4 << 8);

但是还是找不到手册说明。

2.也找到intr2net的讨论:

Subject: 232R device RTS hardware handshake signal

其提到了:

FTDI Chip Commands

其解释了,如何利用libftdi,通过ioctl去发此,ftdi相关的控制命令,其中包括:

setflowctrl:       usb_control_msg(ftdi->usb_dev, 0x40, 0x01,   Value,     Index,           NULL, 0, Timeout)
                        Value encodes cc parameters, etc.  (See ftdi_sio.c in Linux Kernel for details.)
                        Index encodes the following flow control options:
                          0x00   Disable flow control on Channel A
                          0x01   Disable flow control on Channel B
                          0x10   Set RTS/CTS  flow control on Channel A
                          0x11   Set RTS/CTS  flow control on Channel B
                          0x20   Set DTR/DSR  flow control on Channel A
                          0x21   Set DTR/DSR  flow control on Channel B
                          0x40   Set XON/XOFF flow control on Channel A
                          0x41   Set XON/XOFF flow control on Channel B

set DTR:           usb_control_msg(ftdi->usb_dev, 0x40, 0x02,   Value, Interface,           NULL, 0, Timeout)
                        Value is 0x10 to set DTR Low, 0x11 to set DTR High
                        Interface is 0 for Channel A, 1 for Channel B

set RTS:           usb_control_msg(ftdi->usb_dev, 0x40, 0x02,   Value, Interface,           NULL, 0, Timeout)
                        Value is 0x20 to set RTS Low, 0x21 to set RTS High
                        Interface is 0 for Channel A, 1 for Channel B

但是就是不给手册。

3.这里也找到了同样的定义:

smartreader_types.h

4.注意到:

libFTDI – FTDI USB driver with bitbang mode

其只说,此库,只支持:

FT232BM, FT245BM, FT2232C, FT2232D, FT245R and FT232H

没有说,支持FT232R,并且后来通过:

Linux Communication with FT2232C-based USB Devices

看到也只是一直提到FT232C,而也没有提到TF232R,

所以,基本上,可以确定一点是:

其实,上述的libftdi的库,基本的背景逻辑是:

FTDI的232(加上个别245等芯片)都是一系列的,所以对应的基本的这些控制寄存器,

包括flow control的这些寄存器,都是一致的。

所以,可以通过一个libftdi,去操作上述一系列系统,而且还包括没有列出来的,我此处的FT232R,也都是可以正常工作的。

但是,到目前为止,还是没有找到FT232R的,包含了寄存器定义的datasheet。

5.后来也找到一些其他的资料:

http://www.ftdichip.com/Support/Documents/DataSheets/Cables/DS_USB_RS232_PCB.pdf

http://www.ftdichip.com/Support/Documents/DataSheets/Cables/DS_USB_RS232_CABLES.pdf

Upgrading a passive DB9 RS232 Interface to an active USB Interface using an FTDI DB9 – USB – RS232 Module

Future Technology Devices International Ltd Datasheet Chipi – X Cable

但是都没有所要的内容。

 

【总结】

截至目前,没有找到,所需要的,可以详细解释FTDT的FT232R等芯片中的“flow control register ”的位定义的datasheet。

看来是,ftdi只是把定义放出来,大家可以根据此定义写代码,但是对应的datasheet,却没有放出来,所以找不到。

转载请注明:在路上 » 【记录】尝试找到FTDI的USB转串口芯片FT232R中关于流控制的寄存器(FTDI_SIO_SET_FLOW_CTRL或SIO_SET_FLOW_CTRL)的位定义

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
91 queries in 0.186 seconds, using 22.11MB memory