usbhost: adds a driver for the FTDI FT232R USB to serial converter

This commit is contained in:
Nicholas Chin 2020-05-27 15:32:29 -04:00 committed by patacongo
parent 20ef084712
commit 560ba3adcd
4 changed files with 2952 additions and 35 deletions

View File

@ -600,4 +600,96 @@ config USBHOST_TRACE_VERBOSE
endif
config USBHOST_FT232R
bool "FTDI FT232R support"
default n
depends on !USBHOST_BULK_DISABLE && !USBHOST_INT_DISABLE
select SERIAL_REMOVABLE
---help---
Select this option to build in host support for FTDI FT232R
serial devices.
if USBHOST_FT232R
config USBHOST_FT232R_RXDELAY
int "RX poll delay (MSec)"
default 200
---help---
When the CDC/ACM device is inactive, the host must poll it at this
rate in order to discover if it has serial data to send to us.
config USBHOST_FT232R_TXDELAY
int "TX poll delay (MSec)"
default 200
---help---
When the appellation is inactive, the host must poll it at this
rate in order to discover if it has serial data to send to the
device.
config USBHOST_FT232R_NPREALLOC
int "Preallocated state"
default 0
---help---
If this setting is zero, the FT232R driver will allocate
memory as needed for FT232R device state. If this value is non-
zero, then it provides a number of preallocated FT232R state
structures. This increases the static size of the code image, but
eliminates all, direct, run-time allocations by the driver.
config USBHOST_FT232R_BAUD
int "Initialize FT232R BAUD"
default 115200
config USBHOST_FT232R_PARITY
int "Initialize FT232R parity"
default 0
range 0 2
---help---
Initialize FT232R parity. 0=None, 1=Odd, 2=Even. Default: None
config USBHOST_FT232R_BITS
int "Initialize FT232R transfer size"
default 8
range 7 8
---help---
Initialize FT232R number of bits. Default: 8
config USBHOST_FT232R_2STOP
bool "FT232R use two stop bits"
default n
---help---
False = 1 stop bit, True = Two stop bits. Default: 1 stop bit
config USBHOST_FT232R_HWFLOWCTRL
bool "Use FT232R RTS/CTS"
default n
---help---
Enables the FT232R to use its flow control signals
config USBHOST_FT232R_RXBUFSIZE
int "Serial RX buffer size"
default 128
---help---
This is the size of the serial buffer that will be used to hold
received data.
config USBHOST_FT232R_TXBUFSIZE
int "Serial TX buffer size"
default 128
---help---
This is the size of the serial buffer that will be used to hold
data waiting for transmission.
config USBHOST_FT232R_LATENCY
int "Latency Timer"
default 16
range 0 255
---help---
A timeout for UART to USB packet reception. The FT232R will
release its buffer for sending to the USB host once this timeout
occurs or the buffer is full. Measured in ms.
endif # USBHOST_FT232R
endif # USBHOST

View File

@ -74,6 +74,10 @@ ifeq ($(CONFIG_USBHOST_MAX3421E),y)
CSRCS += usbhost_max3421e.c
endif
ifeq ($(CONFIG_USBHOST_FT232R),y)
CSRCS += usbhost_ft232r.c
endif
# HCD debug/trace logic
ifeq ($(CONFIG_USBHOST_TRACE),y)

File diff suppressed because it is too large Load Diff

View File

@ -77,12 +77,12 @@
* Name: CLASS_CREATE
*
* Description:
* This macro will call the create() method of struct usbhost_registry_s. The create()
* method is a callback into the class implementation. It is used to (1) create
* a new instance of the USB host class state and to (2) bind a USB host driver
* "session" to the class instance. Use of this create() method will support
* environments where there may be multiple USB ports and multiple USB devices
* simultaneously connected.
* This macro will call the create() method of struct usbhost_registry_s.
* The create() method is a callback into the class implementation. It is used
* to (1) create a new instance of the USB host class state and to (2) bind a
* USB host driver "session" to the class instance. Use of this create() method
* will support environments where there may be multiple USB ports and multiple
* USB devices simultaneously connected.
*
* Input Parameters:
* reg - The USB host class registry entry previously obtained from a call to
@ -112,14 +112,16 @@
*
* Description:
* This macro will call the connect() method of struct usbhost_class_s. This
* method is a callback into the devclass implementation. It is used to provide the
* device's configuration descriptor to the devclass so that the devclass may initialize
* properly
* method is a callback into the devclass implementation. It is used to provide
* the device's configuration descriptor to the devclass so that the devclass may
* initialize properly.
*
* Input Parameters:
* devclass - The USB host class entry previously obtained from a call to create().
* configdesc - A pointer to a uint8_t buffer container the configuration descriptor.
* desclen - The length in bytes of the configuration descriptor.
* devclass - The USB host class entry previously obtained from a call
* to create().
* configdesc - A pointer to a uint8_t buffer containing the configuration
* descriptor.
* desclen - The length in bytes of the configuration descriptor.
*
* Returned Value:
* On success, zero (OK) is returned. On a failure, a negated errno value is
@ -163,7 +165,7 @@
#define CLASS_DISCONNECTED(devclass) ((devclass)->disconnected(devclass))
/****************************************************************************
/************************************************************************************
* Name: CONN_WAIT
*
* Description:
@ -186,7 +188,7 @@
* - Called from a single thread so no mutual exclusion is required.
* - Never called from an interrupt handler.
*
****************************************************************************/
************************************************************************************/
#define CONN_WAIT(conn,hport) ((conn)->wait(conn,hport))
@ -644,8 +646,8 @@ struct usbhost_id_s
* connected to the USB port.
*/
struct usbhost_hubport_s; /* Forward reference to the hub state structure */
struct usbhost_class_s; /* Forward reference to the class state structure */
struct usbhost_hubport_s; /* Forward reference to the hub state structure */
struct usbhost_class_s; /* Forward reference to the class state structure */
struct usbhost_registry_s
{
/* This field is used to implement a singly-link registry structure. Because of
@ -730,9 +732,9 @@ struct usbhost_roothubport_s
struct usbhost_class_s
{
/* Class instances are associated with devices connected on one port on a
* hub and are represented by this structure.
*/
/* Class instances are associated with devices connected on one port on a
* hub and are represented by this structure.
*/
FAR struct usbhost_hubport_s *hport; /* The port used by this class instance */
@ -985,7 +987,7 @@ const struct usbhost_registry_s *
usbhost_findclass(FAR const struct usbhost_id_s *id);
#ifdef CONFIG_USBHOST_HUB
/****************************************************************************
/***********************************************************************************
* Name: usbhost_hub_initialize
*
* Description:
@ -1000,13 +1002,13 @@ const struct usbhost_registry_s *
* On success this function will return zero (OK); A negated errno value
* will be returned on failure.
*
****************************************************************************/
************************************************************************************/
int usbhost_hub_initialize(void);
#endif
#ifdef CONFIG_USBHOST_MSC
/****************************************************************************
/************************************************************************************
* Name: usbhost_msc_initialize
*
* Description:
@ -1021,13 +1023,13 @@ int usbhost_hub_initialize(void);
* On success this function will return zero (OK); A negated errno value
* will be returned on failure.
*
****************************************************************************/
************************************************************************************/
int usbhost_msc_initialize(void);
#endif
#ifdef CONFIG_USBHOST_CDCACM
/****************************************************************************
/************************************************************************************
* Name: usbhost_cdcacm_initialize
*
* Description:
@ -1042,13 +1044,34 @@ int usbhost_msc_initialize(void);
* On success this function will return zero (OK); A negated errno value
* will be returned on failure.
*
****************************************************************************/
************************************************************************************/
int usbhost_cdcacm_initialize(void);
#endif
#ifdef CONFIG_USBHOST_FT232R
/************************************************************************************
* Name: usbhost_ft232r_initialize
*
* Description:
* Initialize the USB FT232R driver. This function should be called
* be platform-specific code in order to initialize and register support
* for the FT232R.
*
* Input Parameters:
* None
*
* Returned Value:
* On success this function will return zero (OK); A negated errno value
* will be returned on failure.
*
************************************************************************************/
int usbhost_ft232r_initialize(void);
#endif
#ifdef CONFIG_USBHOST_HIDKBD
/****************************************************************************
/************************************************************************************
* Name: usbhost_kbdinit
*
* Description:
@ -1063,13 +1086,13 @@ int usbhost_cdcacm_initialize(void);
* On success this function will return zero (OK); A negated errno value
* will be returned on failure.
*
****************************************************************************/
************************************************************************************/
int usbhost_kbdinit(void);
#endif
#ifdef CONFIG_USBHOST_HIDMOUSE
/****************************************************************************
/************************************************************************************
* Name: usbhost_mouse_init
*
* Description:
@ -1084,13 +1107,13 @@ int usbhost_kbdinit(void);
* On success this function will return zero (OK); A negated errno value
* will be returned on failure.
*
****************************************************************************/
************************************************************************************/
int usbhost_mouse_init(void);
#endif
#ifdef CONFIG_USBHOST_XBOXCONTROLLER
/****************************************************************************
/************************************************************************************
* Name: usbhost_xboxcontroller_init
*
* Description:
@ -1105,12 +1128,12 @@ int usbhost_mouse_init(void);
* On success this function will return zero (OK); A negated errno value
* will be returned on failure.
*
****************************************************************************/
************************************************************************************/
int usbhost_xboxcontroller_init(void);
#endif
/****************************************************************************
/************************************************************************************
* Name: usbhost_wlaninit
*
* Description:
@ -1125,11 +1148,11 @@ int usbhost_xboxcontroller_init(void);
* On success this function will return zero (OK); A negated errno value
* will be returned on failure.
*
****************************************************************************/
************************************************************************************/
int usbhost_wlaninit(void);
/****************************************************************************
/************************************************************************************
* Name: usbhost_enumerate
*
* Description:
@ -1161,7 +1184,7 @@ int usbhost_wlaninit(void);
* - Called from a single thread so no mutual exclusion is required.
* - Never called from an interrupt handler.
*
****************************************************************************/
************************************************************************************/
int usbhost_enumerate(FAR struct usbhost_hubport_s *hub,
FAR struct usbhost_class_s **devclass);