2008-10-22 16:20:18 +00:00
|
|
|
/************************************************************************************
|
2010-12-14 03:33:39 +00:00
|
|
|
* include/nuttx/usb/usbhost.h
|
2008-10-22 16:20:18 +00:00
|
|
|
*
|
2013-08-12 14:44:06 -06:00
|
|
|
* Copyright (C) 2010-2013 Gregory Nutt. All rights reserved.
|
2012-07-17 03:58:11 +00:00
|
|
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
2008-10-22 16:20:18 +00:00
|
|
|
*
|
|
|
|
|
* References:
|
|
|
|
|
* "Universal Serial Bus Mass Storage Class, Specification Overview,"
|
|
|
|
|
* Revision 1.2, USB Implementer's Forum, June 23, 2003.
|
|
|
|
|
*
|
|
|
|
|
* "Universal Serial Bus Mass Storage Class, Bulk-Only Transport,"
|
|
|
|
|
* Revision 1.0, USB Implementer's Forum, September 31, 1999.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
|
* are met:
|
|
|
|
|
*
|
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
|
* distribution.
|
|
|
|
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
|
|
|
* used to endorse or promote products derived from this software
|
|
|
|
|
* without specific prior written permission.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
*
|
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
2012-07-17 03:58:11 +00:00
|
|
|
#ifndef __INCLUDE_NUTTX_USB_USBHOST_H
|
|
|
|
|
#define __INCLUDE_NUTTX_USB_USBHOST_H
|
2008-10-22 16:20:18 +00:00
|
|
|
|
|
|
|
|
/************************************************************************************
|
|
|
|
|
* Included Files
|
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
2010-12-16 00:49:02 +00:00
|
|
|
|
2010-12-17 02:19:04 +00:00
|
|
|
#include <sys/types.h>
|
2009-12-14 23:32:23 +00:00
|
|
|
#include <stdint.h>
|
2010-12-16 00:49:02 +00:00
|
|
|
#include <stdbool.h>
|
2008-10-22 16:20:18 +00:00
|
|
|
|
|
|
|
|
/************************************************************************************
|
2009-12-14 23:32:23 +00:00
|
|
|
* Pre-processor Definitions
|
2008-10-22 16:20:18 +00:00
|
|
|
************************************************************************************/
|
|
|
|
|
|
|
|
|
|
/************************************************************************************
|
2010-12-14 15:24:50 +00:00
|
|
|
* Name: CLASS_CREATE
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
2010-12-15 03:30:20 +00:00
|
|
|
* This macro will call the create() method of struct usbhost_registry_s. The create()
|
2010-12-14 15:24:50 +00:00
|
|
|
* 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
|
|
|
|
|
* usbhost_findclass().
|
|
|
|
|
* drvr - An instance of struct usbhost_driver_s that the class implementation will
|
|
|
|
|
* "bind" to its state structure and will subsequently use to communicate with
|
|
|
|
|
* the USB host driver.
|
2010-12-14 19:02:49 +00:00
|
|
|
* id - In the case where the device supports multiple base classes, subclasses, or
|
|
|
|
|
* protocols, this specifies which to configure for.
|
2010-12-14 15:24:50 +00:00
|
|
|
*
|
|
|
|
|
* Returned Values:
|
|
|
|
|
* On success, this function will return a non-NULL instance of struct
|
|
|
|
|
* usbhost_class_s that can be used by the USB host driver to communicate with the
|
|
|
|
|
* USB host class. NULL is returned on failure; this function will fail only if
|
|
|
|
|
* the drvr input parameter is NULL or if there are insufficient resources to
|
|
|
|
|
* create another USB host class instance.
|
|
|
|
|
*
|
2010-12-16 02:06:24 +00:00
|
|
|
* Assumptions:
|
|
|
|
|
* If this function is called from an interrupt handler, it will be unable to
|
|
|
|
|
* allocate memory and CONFIG_USBHOST_NPREALLOC should be defined to be a value
|
|
|
|
|
* greater than zero specify a number of pre-allocated class structures.
|
|
|
|
|
*
|
2008-10-22 16:20:18 +00:00
|
|
|
************************************************************************************/
|
|
|
|
|
|
2010-12-19 19:18:29 +00:00
|
|
|
#define CLASS_CREATE(reg, drvr, id) ((reg)->create(drvr, id))
|
2010-12-15 03:30:20 +00:00
|
|
|
|
|
|
|
|
/************************************************************************************
|
2010-12-21 11:21:07 +00:00
|
|
|
* Name: CLASS_CONNECT
|
2010-12-15 03:30:20 +00:00
|
|
|
*
|
|
|
|
|
* Description:
|
2010-12-21 11:21:07 +00:00
|
|
|
* This macro will call the connect() method of struct usbhost_class_s. This
|
2010-12-15 03:30:20 +00:00
|
|
|
* method is a callback into the class implementation. It is used to provide the
|
|
|
|
|
* device's configuration descriptor to the class so that the class may initialize
|
|
|
|
|
* properly
|
|
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* class - The USB host class entry previously obtained from a call to create().
|
|
|
|
|
* configdesc - A pointer to a uint8_t buffer container the configuration descripor.
|
|
|
|
|
* desclen - The length in bytes of the configuration descriptor.
|
2011-01-02 20:05:28 +00:00
|
|
|
* funcaddr - The USB address of the function containing the endpoint that EP0
|
|
|
|
|
* controls
|
2010-12-15 03:30:20 +00:00
|
|
|
*
|
|
|
|
|
* Returned Values:
|
|
|
|
|
* On success, zero (OK) is returned. On a failure, a negated errno value is
|
|
|
|
|
* returned indicating the nature of the failure
|
|
|
|
|
*
|
2011-05-12 12:58:56 +00:00
|
|
|
* NOTE that the class instance remains valid upon return with a failure. It is
|
|
|
|
|
* the responsibility of the higher level enumeration logic to call
|
|
|
|
|
* CLASS_DISCONNECTED to free up the class driver resources.
|
|
|
|
|
*
|
2010-12-16 02:06:24 +00:00
|
|
|
* Assumptions:
|
2011-01-17 13:52:33 +00:00
|
|
|
* - This function is probably called on the same thread that called the driver
|
|
|
|
|
* enumerate() method. This function will *not* be called from an interrupt
|
|
|
|
|
* handler.
|
|
|
|
|
* - If this function returns an error, the USB host controller driver
|
|
|
|
|
* must call to DISCONNECTED method to recover from the error
|
2010-12-16 02:06:24 +00:00
|
|
|
*
|
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
2011-01-02 20:05:28 +00:00
|
|
|
#define CLASS_CONNECT(class,configdesc,desclen,funcaddr) \
|
|
|
|
|
((class)->connect(class,configdesc,desclen, funcaddr))
|
2010-12-16 02:06:24 +00:00
|
|
|
|
2010-12-15 18:39:19 +00:00
|
|
|
/************************************************************************************
|
|
|
|
|
* Name: CLASS_DISCONNECTED
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* This macro will call the disconnected() method of struct usbhost_class_s. This
|
|
|
|
|
* method is a callback into the class implementation. It is used to inform the
|
|
|
|
|
* class that the USB device has been disconnected.
|
|
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* class - The USB host class entry previously obtained from a call to create().
|
|
|
|
|
*
|
|
|
|
|
* Returned Values:
|
|
|
|
|
* On success, zero (OK) is returned. On a failure, a negated errno value is
|
|
|
|
|
* returned indicating the nature of the failure
|
|
|
|
|
*
|
2010-12-16 02:06:24 +00:00
|
|
|
* Assumptions:
|
2011-01-11 01:41:06 +00:00
|
|
|
* This function will *not* be called from an interrupt handler.
|
2010-12-16 02:06:24 +00:00
|
|
|
*
|
2010-12-15 18:39:19 +00:00
|
|
|
************************************************************************************/
|
|
|
|
|
|
2010-12-16 00:33:12 +00:00
|
|
|
#define CLASS_DISCONNECTED(class) ((class)->disconnected(class))
|
2010-12-14 15:24:50 +00:00
|
|
|
|
2010-12-21 01:41:03 +00:00
|
|
|
/*******************************************************************************
|
2013-08-13 15:03:46 -06:00
|
|
|
* Name: CONN_WAIT
|
2010-12-21 01:41:03 +00:00
|
|
|
*
|
|
|
|
|
* Description:
|
2013-08-12 14:44:06 -06:00
|
|
|
* Wait for a device to be connected or disconnected to/from a root hub port.
|
2010-12-21 01:41:03 +00:00
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
2013-08-13 15:03:46 -06:00
|
|
|
* conn - The USB host connection instance obtained as a parameter from the call to
|
|
|
|
|
* the USB driver initialization logic.
|
2013-08-12 14:44:06 -06:00
|
|
|
* connected - A pointer to an array of n boolean values corresponding to
|
|
|
|
|
* root hubs 1 through n. For each boolean value: TRUE: Wait for a device
|
|
|
|
|
* to be connected on the root hub; FALSE: wait for device to be
|
|
|
|
|
* disconnected from the root hub.
|
2010-12-21 01:41:03 +00:00
|
|
|
*
|
|
|
|
|
* Returned Values:
|
2013-08-12 14:44:06 -06:00
|
|
|
* And index [0..(n-1)} corresponding to the root hub port number {1..n} is
|
|
|
|
|
* returned when a device in connected or disconnectd. This function will not
|
|
|
|
|
* return until either (1) a device is connected or disconntect to/from any
|
|
|
|
|
* root hub port or until (2) some failure occurs. On a failure, a negated
|
|
|
|
|
* errno value is returned indicating the nature of the failure
|
2010-12-21 01:41:03 +00:00
|
|
|
*
|
|
|
|
|
* Assumptions:
|
2013-08-12 14:44:06 -06:00
|
|
|
* - Called from a single thread so no mutual exclusion is required.
|
|
|
|
|
* - Never called from an interrupt handler.
|
2010-12-21 01:41:03 +00:00
|
|
|
*
|
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
2013-08-13 15:03:46 -06:00
|
|
|
#define CONN_WAIT(conn, connected) ((conn)->wait(conn,connected))
|
2010-12-21 01:41:03 +00:00
|
|
|
|
2010-12-17 02:19:04 +00:00
|
|
|
/************************************************************************************
|
2013-08-13 15:03:46 -06:00
|
|
|
* Name: CONN_ENUMERATE
|
2010-12-17 02:19:04 +00:00
|
|
|
*
|
|
|
|
|
* Description:
|
2010-12-21 01:41:03 +00:00
|
|
|
* Enumerate the connected device. As part of this enumeration process,
|
|
|
|
|
* the driver will (1) get the device's configuration descriptor, (2)
|
|
|
|
|
* extract the class ID info from the configuration descriptor, (3) call
|
|
|
|
|
* usbhost_findclass() to find the class that supports this device, (4)
|
|
|
|
|
* call the create() method on the struct usbhost_registry_s interface
|
2010-12-21 11:21:07 +00:00
|
|
|
* to get a class instance, and finally (5) call the connect() method
|
2010-12-21 01:41:03 +00:00
|
|
|
* of the struct usbhost_class_s interface. After that, the class is in
|
|
|
|
|
* charge of the sequence of operations.
|
2010-12-17 02:19:04 +00:00
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
2013-08-13 15:03:46 -06:00
|
|
|
* conn - The USB host connection instance obtained as a parameter from the call to
|
|
|
|
|
* the USB driver initialization logic.
|
2013-08-12 14:44:06 -06:00
|
|
|
* rphndx - Root hub port index. 0-(n-1) corresponds to root hub port 1-n.
|
2010-12-17 02:19:04 +00:00
|
|
|
*
|
|
|
|
|
* Returned Values:
|
|
|
|
|
* On success, zero (OK) is returned. On a failure, a negated errno value is
|
|
|
|
|
* returned indicating the nature of the failure
|
|
|
|
|
*
|
|
|
|
|
* Assumptions:
|
|
|
|
|
* This function will *not* be called from an interrupt handler.
|
|
|
|
|
*
|
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
2013-08-13 15:03:46 -06:00
|
|
|
#define CONN_ENUMERATE(conn,rhpndx) ((conn)->enumerate(conn,rhpndx))
|
2010-12-17 02:19:04 +00:00
|
|
|
|
2010-12-28 02:22:11 +00:00
|
|
|
/************************************************************************************
|
|
|
|
|
* Name: DRVR_EP0CONFIGURE
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* Configure endpoint 0. This method is normally used internally by the
|
|
|
|
|
* enumerate() method but is made available at the interface to support
|
|
|
|
|
* an external implementation of the enumeration logic.
|
|
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* drvr - The USB host driver instance obtained as a parameter from the call to
|
|
|
|
|
* the class create() method.
|
2011-01-01 15:08:18 +00:00
|
|
|
* funcaddr - The USB address of the function containing the endpoint that EP0
|
2010-12-28 02:22:11 +00:00
|
|
|
* controls
|
|
|
|
|
* mps (maxpacketsize) - The maximum number of bytes that can be sent to or
|
|
|
|
|
* received from the endpoint in a single data packet
|
|
|
|
|
*
|
|
|
|
|
* Returned Values:
|
|
|
|
|
* On success, zero (OK) is returned. On a failure, a negated errno value is
|
|
|
|
|
* returned indicating the nature of the failure
|
|
|
|
|
*
|
|
|
|
|
* Assumptions:
|
|
|
|
|
* This function will *not* be called from an interrupt handler.
|
|
|
|
|
*
|
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
2011-01-01 15:08:18 +00:00
|
|
|
#define DRVR_EP0CONFIGURE(drvr,funcaddr,mps) ((drvr)->ep0configure(drvr,funcaddr,mps))
|
2010-12-28 02:22:11 +00:00
|
|
|
|
2011-01-11 01:41:06 +00:00
|
|
|
/************************************************************************************
|
|
|
|
|
* Name: DRVR_EPALLOC
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* Allocate and configure one endpoint.
|
|
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* drvr - The USB host driver instance obtained as a parameter from the call to
|
|
|
|
|
* the class create() method.
|
|
|
|
|
* epdesc - Describes the endpoint to be allocated.
|
|
|
|
|
* ep - A memory location provided by the caller in which to receive the
|
|
|
|
|
* allocated endpoint desciptor.
|
|
|
|
|
*
|
|
|
|
|
* Returned Values:
|
|
|
|
|
* On success, zero (OK) is returned. On a failure, a negated errno value is
|
|
|
|
|
* returned indicating the nature of the failure
|
|
|
|
|
*
|
|
|
|
|
* Assumptions:
|
|
|
|
|
* This function will *not* be called from an interrupt handler.
|
|
|
|
|
*
|
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define DRVR_EPALLOC(drvr,epdesc,ep) ((drvr)->epalloc(drvr,epdesc,ep))
|
|
|
|
|
|
|
|
|
|
/************************************************************************************
|
|
|
|
|
* Name: DRVR_EPFREE
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* Free and endpoint previously allocated by DRVR_EPALLOC.
|
|
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* drvr - The USB host driver instance obtained as a parameter from the call to
|
|
|
|
|
* the class create() method.
|
|
|
|
|
* ep - The endpint to be freed.
|
|
|
|
|
*
|
|
|
|
|
* Returned Values:
|
|
|
|
|
* On success, zero (OK) is returned. On a failure, a negated errno value is
|
|
|
|
|
* returned indicating the nature of the failure
|
|
|
|
|
*
|
|
|
|
|
* Assumptions:
|
|
|
|
|
* This function will *not* be called from an interrupt handler.
|
|
|
|
|
*
|
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define DRVR_EPFREE(drvr,ep) ((drvr)->epfree(drvr,ep))
|
|
|
|
|
|
2010-12-17 02:19:04 +00:00
|
|
|
/************************************************************************************
|
2010-12-18 03:24:13 +00:00
|
|
|
* Name: DRVR_ALLOC
|
2010-12-17 02:19:04 +00:00
|
|
|
*
|
|
|
|
|
* Description:
|
2011-01-15 17:46:55 +00:00
|
|
|
* Some hardware supports special memory in which request and descriptor data can
|
2010-12-18 03:24:13 +00:00
|
|
|
* be accessed more efficiently. This method provides a mechanism to allocate
|
2011-01-15 17:46:55 +00:00
|
|
|
* the request/descriptor memory. If the underlying hardware does not support
|
2012-08-21 20:14:42 +00:00
|
|
|
* such "special" memory, this functions may simply map to kmalloc.
|
2010-12-17 02:19:04 +00:00
|
|
|
*
|
2011-03-25 22:56:36 +00:00
|
|
|
* This interface was optimized under a particular assumption. It was assumed
|
|
|
|
|
* that the driver maintains a pool of small, pre-allocated buffers for descriptor
|
|
|
|
|
* traffic. NOTE that size is not an input, but an output: The size of the
|
|
|
|
|
* pre-allocated buffer is returned.
|
|
|
|
|
*
|
2010-12-17 02:19:04 +00:00
|
|
|
* Input Parameters:
|
|
|
|
|
* drvr - The USB host driver instance obtained as a parameter from the call to
|
|
|
|
|
* the class create() method.
|
2010-12-18 03:24:13 +00:00
|
|
|
* buffer - The address of a memory location provided by the caller in which to
|
|
|
|
|
* return the allocated buffer memory address.
|
|
|
|
|
* maxlen - The address of a memory location provided by the caller in which to
|
|
|
|
|
* return the maximum size of the allocated buffer memory.
|
2010-12-17 02:19:04 +00:00
|
|
|
*
|
|
|
|
|
* Returned Values:
|
|
|
|
|
* On success, zero (OK) is returned. On a failure, a negated errno value is
|
|
|
|
|
* returned indicating the nature of the failure
|
|
|
|
|
*
|
|
|
|
|
* Assumptions:
|
|
|
|
|
* This function will *not* be called from an interrupt handler.
|
|
|
|
|
*
|
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
2010-12-18 03:24:13 +00:00
|
|
|
#define DRVR_ALLOC(drvr,buffer,maxlen) ((drvr)->alloc(drvr,buffer,maxlen))
|
2010-12-17 02:19:04 +00:00
|
|
|
|
|
|
|
|
/************************************************************************************
|
2010-12-18 03:24:13 +00:00
|
|
|
* Name: DRVR_FREE
|
2010-12-17 02:19:04 +00:00
|
|
|
*
|
|
|
|
|
* Description:
|
2011-01-15 17:46:55 +00:00
|
|
|
* Some hardware supports special memory in which request and descriptor data can
|
2010-12-18 03:24:13 +00:00
|
|
|
* be accessed more efficiently. This method provides a mechanism to free that
|
2011-01-15 17:46:55 +00:00
|
|
|
* request/descriptor memory. If the underlying hardware does not support
|
2012-08-21 20:14:42 +00:00
|
|
|
* such "special" memory, this functions may simply map to kfree().
|
2010-12-17 02:19:04 +00:00
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* drvr - The USB host driver instance obtained as a parameter from the call to
|
|
|
|
|
* the class create() method.
|
2010-12-18 03:24:13 +00:00
|
|
|
* buffer - The address of the allocated buffer memory to be freed.
|
2010-12-17 02:19:04 +00:00
|
|
|
*
|
|
|
|
|
* Returned Values:
|
|
|
|
|
* On success, zero (OK) is returned. On a failure, a negated errno value is
|
|
|
|
|
* returned indicating the nature of the failure
|
|
|
|
|
*
|
|
|
|
|
* Assumptions:
|
|
|
|
|
* This function will *not* be called from an interrupt handler.
|
|
|
|
|
*
|
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
2010-12-18 03:24:13 +00:00
|
|
|
#define DRVR_FREE(drvr,buffer) ((drvr)->free(drvr,buffer))
|
2010-12-17 02:19:04 +00:00
|
|
|
|
2011-03-25 22:56:36 +00:00
|
|
|
/************************************************************************************
|
|
|
|
|
* Name: DRVR_IOALLOC
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* Some hardware supports special memory in which larger IO buffers can
|
|
|
|
|
* be accessed more efficiently. This method provides a mechanism to allocate
|
|
|
|
|
* the request/descriptor memory. If the underlying hardware does not support
|
2012-08-21 20:14:42 +00:00
|
|
|
* such "special" memory, this functions may simply map to kmalloc.
|
2011-03-25 22:56:36 +00:00
|
|
|
*
|
|
|
|
|
* This interface differs from DRVR_ALLOC in that the buffers are variable-sized.
|
|
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* drvr - The USB host driver instance obtained as a parameter from the call to
|
|
|
|
|
* the class create() method.
|
|
|
|
|
* buffer - The address of a memory location provided by the caller in which to
|
|
|
|
|
* return the allocated buffer memory address.
|
|
|
|
|
* buflen - The size of the buffer required.
|
|
|
|
|
*
|
|
|
|
|
* Returned Values:
|
|
|
|
|
* On success, zero (OK) is returned. On a failure, a negated errno value is
|
|
|
|
|
* returned indicating the nature of the failure
|
|
|
|
|
*
|
|
|
|
|
* Assumptions:
|
|
|
|
|
* This function will *not* be called from an interrupt handler.
|
|
|
|
|
*
|
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define DRVR_IOALLOC(drvr,buffer,buflen) ((drvr)->ioalloc(drvr,buffer,buflen))
|
|
|
|
|
|
|
|
|
|
/************************************************************************************
|
|
|
|
|
* Name: DRVR_IOFREE
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* Some hardware supports special memory in which IO data can be accessed more
|
|
|
|
|
* efficiently. This method provides a mechanism to free that IO buffer
|
|
|
|
|
* memory. If the underlying hardware does not support such "special" memory,
|
2012-08-21 20:14:42 +00:00
|
|
|
* this functions may simply map to kfree().
|
2011-03-25 22:56:36 +00:00
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* drvr - The USB host driver instance obtained as a parameter from the call to
|
|
|
|
|
* the class create() method.
|
|
|
|
|
* buffer - The address of the allocated buffer memory to be freed.
|
|
|
|
|
*
|
|
|
|
|
* Returned Values:
|
|
|
|
|
* On success, zero (OK) is returned. On a failure, a negated errno value is
|
|
|
|
|
* returned indicating the nature of the failure
|
|
|
|
|
*
|
|
|
|
|
* Assumptions:
|
|
|
|
|
* This function will *not* be called from an interrupt handler.
|
|
|
|
|
*
|
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define DRVR_IOFREE(drvr,buffer) ((drvr)->iofree(drvr,buffer))
|
|
|
|
|
|
2010-12-17 02:19:04 +00:00
|
|
|
/************************************************************************************
|
2010-12-20 16:51:15 +00:00
|
|
|
* Name: DRVR_CTRLIN and DRVR_CTRLOUT
|
2010-12-17 02:19:04 +00:00
|
|
|
*
|
|
|
|
|
* Description:
|
2010-12-20 16:51:15 +00:00
|
|
|
* Process a IN or OUT request on the control endpoint. These methods
|
2010-12-20 20:59:12 +00:00
|
|
|
* will enqueue the request and wait for it to complete. Only one transfer may be
|
2010-12-20 16:51:15 +00:00
|
|
|
* queued; Neither these methods nor the transfer() method can be called again
|
|
|
|
|
* until the control transfer functions returns.
|
|
|
|
|
*
|
|
|
|
|
* These are blocking methods; these functions will not return until the
|
|
|
|
|
* control transfer has completed.
|
2010-12-17 02:19:04 +00:00
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* drvr - The USB host driver instance obtained as a parameter from the call to
|
|
|
|
|
* the class create() method.
|
2010-12-21 15:57:40 +00:00
|
|
|
* req - Describes the request to be sent. This request must lie in memory
|
|
|
|
|
* created by DRVR_ALLOC.
|
2010-12-18 03:24:13 +00:00
|
|
|
* buffer - A buffer used for sending the request and for returning any
|
|
|
|
|
* responses. This buffer must be large enough to hold the length value
|
2010-12-21 15:57:40 +00:00
|
|
|
* in the request description. buffer must have been allocated using DRVR_ALLOC.
|
|
|
|
|
*
|
|
|
|
|
* NOTE: On an IN transaction, req and buffer may refer to the same allocated
|
|
|
|
|
* memory.
|
2010-12-17 02:19:04 +00:00
|
|
|
*
|
|
|
|
|
* Returned Values:
|
|
|
|
|
* On success, zero (OK) is returned. On a failure, a negated errno value is
|
|
|
|
|
* returned indicating the nature of the failure
|
|
|
|
|
*
|
|
|
|
|
* Assumptions:
|
|
|
|
|
* This function will *not* be called from an interrupt handler.
|
|
|
|
|
*
|
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
2010-12-20 16:51:15 +00:00
|
|
|
#define DRVR_CTRLIN(drvr,req,buffer) ((drvr)->ctrlin(drvr,req,buffer))
|
|
|
|
|
#define DRVR_CTRLOUT(drvr,req,buffer) ((drvr)->ctrlout(drvr,req,buffer))
|
2010-12-18 03:24:13 +00:00
|
|
|
|
|
|
|
|
/************************************************************************************
|
|
|
|
|
* Name: DRVR_TRANSFER
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
2010-12-20 16:51:15 +00:00
|
|
|
* Process a request to handle a transfer descriptor. This method will
|
2010-12-20 20:59:12 +00:00
|
|
|
* enqueue the transfer request and rwait for it to complete. Only one transfer may
|
|
|
|
|
* be queued; Neither this method nor the ctrlin or ctrlout methods can be called
|
2010-12-20 16:51:15 +00:00
|
|
|
* again until this function returns.
|
|
|
|
|
*
|
|
|
|
|
* This is a blocking method; this functions will not return until the
|
|
|
|
|
* transfer has completed.
|
2010-12-18 03:24:13 +00:00
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* drvr - The USB host driver instance obtained as a parameter from the call to
|
|
|
|
|
* the class create() method.
|
|
|
|
|
* ed - The IN or OUT endpoint descriptor for the device endpoint on which to
|
|
|
|
|
* perform the transfer.
|
|
|
|
|
* buffer - A buffer containing the data to be sent (OUT endpoint) or received
|
|
|
|
|
* (IN endpoint). buffer must have been allocated using DRVR_ALLOC
|
|
|
|
|
* buflen - The length of the data to be sent or received.
|
|
|
|
|
*
|
|
|
|
|
* Returned Values:
|
|
|
|
|
* On success, zero (OK) is returned. On a failure, a negated errno value is
|
2012-08-24 22:16:09 +00:00
|
|
|
* returned indicating the nature of the failure:
|
|
|
|
|
*
|
|
|
|
|
* EAGAIN - If devices NAKs the transfer (or NYET or other error where
|
|
|
|
|
* it may be appropriate to restart the entire transaction).
|
|
|
|
|
* EPERM - If the endpoint stalls
|
|
|
|
|
* EIO - On a TX or data toggle error
|
|
|
|
|
* EPIPE - Overrun errors
|
2010-12-18 03:24:13 +00:00
|
|
|
*
|
|
|
|
|
* Assumptions:
|
|
|
|
|
* This function will *not* be called from an interrupt handler.
|
|
|
|
|
*
|
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define DRVR_TRANSFER(drvr,ed,buffer,buflen) ((drvr)->transfer(drvr,ed,buffer,buflen))
|
2010-12-17 02:19:04 +00:00
|
|
|
|
2010-12-18 17:35:54 +00:00
|
|
|
/************************************************************************************
|
|
|
|
|
* Name: DRVR_DISCONNECT
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* Called by the class when an error occurs and driver has been disconnected.
|
|
|
|
|
* The USB host driver should discard the handle to the class instance (it is
|
|
|
|
|
* stale) and not attempt any further interaction with the class driver instance
|
|
|
|
|
* (until a new instance is received from the create() method). The driver
|
|
|
|
|
* should not called the class' disconnected() method.
|
|
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* drvr - The USB host driver instance obtained as a parameter from the call to
|
|
|
|
|
* the class create() method.
|
|
|
|
|
*
|
|
|
|
|
* Returned Values:
|
|
|
|
|
* None
|
|
|
|
|
*
|
|
|
|
|
* Assumptions:
|
|
|
|
|
* This function will *not* be called from an interrupt handler.
|
|
|
|
|
*
|
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
2013-08-13 14:12:27 -06:00
|
|
|
#define DRVR_DISCONNECT(drvr) ((drvr)->disconnect(drvr))
|
2010-12-18 17:35:54 +00:00
|
|
|
|
2008-10-22 16:20:18 +00:00
|
|
|
/************************************************************************************
|
2010-12-14 15:24:50 +00:00
|
|
|
* Public Types
|
2008-10-22 16:20:18 +00:00
|
|
|
************************************************************************************/
|
|
|
|
|
|
2010-12-14 15:24:50 +00:00
|
|
|
/* This struct contains all of the information that is needed to associate a device
|
|
|
|
|
* this is connected via a USB port to a class.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
struct usbhost_id_s
|
|
|
|
|
{
|
2010-12-14 19:02:49 +00:00
|
|
|
uint8_t base; /* Base device class code (see USB_CLASS_* defines in usb.h) */
|
2012-01-25 20:17:59 +00:00
|
|
|
uint8_t subclass; /* Sub-class, depends on base class. Eg., See USBMSC_SUBCLASS_* */
|
|
|
|
|
uint8_t proto; /* Protocol, depends on base class. Eg., See USBMSC_PROTO_* */
|
2010-12-14 19:02:49 +00:00
|
|
|
uint16_t vid; /* Vendor ID (for vendor/product specific devices) */
|
|
|
|
|
uint16_t pid; /* Product ID (for vendor/product specific devices) */
|
2010-12-14 15:24:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* The struct usbhost_registry_s type describes information that is kept in the the
|
|
|
|
|
* USB host registry. USB host class implementations register this information so
|
|
|
|
|
* that USB host drivers can later find the class that matches the device that is
|
|
|
|
|
* connected to the USB port.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
struct usbhost_driver_s; /* Forward reference to the driver 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
|
|
|
|
|
* the presence of this link, provides of structy usbhost_registry_s instances must
|
|
|
|
|
* provide those instances in write-able memory (RAM).
|
|
|
|
|
*/
|
|
|
|
|
|
2010-12-16 00:33:12 +00:00
|
|
|
struct usbhost_registry_s *flink;
|
2010-12-14 15:24:50 +00:00
|
|
|
|
|
|
|
|
/* This 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 (see the CLASS_CREATE() macro above).
|
|
|
|
|
*/
|
|
|
|
|
|
2010-12-15 18:39:19 +00:00
|
|
|
FAR struct usbhost_class_s *(*create)(FAR struct usbhost_driver_s *drvr,
|
2010-12-16 00:33:12 +00:00
|
|
|
FAR const struct usbhost_id_s *id);
|
2010-12-14 15:24:50 +00:00
|
|
|
|
|
|
|
|
/* This information uniquely identifies the USB host class implementation that
|
|
|
|
|
* goes with a specific USB device.
|
|
|
|
|
*/
|
|
|
|
|
|
2010-12-15 18:39:19 +00:00
|
|
|
uint8_t nids; /* Number of IDs in the id[] array */
|
|
|
|
|
FAR const struct usbhost_id_s *id; /* An array of ID info. Actual dimension is nids */
|
2010-12-15 03:12:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* struct usbhost_class_s provides access from the USB host driver to the USB host
|
|
|
|
|
* class implementation.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
struct usbhost_class_s
|
|
|
|
|
{
|
2010-12-15 18:39:19 +00:00
|
|
|
/* Provides the configuration descriptor to the class. The configuration
|
2010-12-15 03:12:09 +00:00
|
|
|
* descriptor contains critical information needed by the class in order to
|
|
|
|
|
* initialize properly (such as endpoint selections).
|
|
|
|
|
*/
|
|
|
|
|
|
2011-01-02 20:05:28 +00:00
|
|
|
int (*connect)(FAR struct usbhost_class_s *class, FAR const uint8_t *configdesc,
|
|
|
|
|
int desclen, uint8_t funcaddr);
|
2010-12-16 02:06:24 +00:00
|
|
|
|
2010-12-15 18:39:19 +00:00
|
|
|
/* This method informs the class that the USB device has been disconnected. */
|
|
|
|
|
|
|
|
|
|
int (*disconnected)(FAR struct usbhost_class_s *class);
|
2010-12-15 03:12:09 +00:00
|
|
|
};
|
|
|
|
|
|
2011-01-11 01:41:06 +00:00
|
|
|
/* This structure describes one endpoint. It is used as an input to the
|
2012-08-20 13:55:19 +00:00
|
|
|
* epalloc() method. Most of this information comes from the endpoint
|
2011-01-16 14:02:42 +00:00
|
|
|
* descriptor.
|
2011-01-11 01:41:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
struct usbhost_epdesc_s
|
|
|
|
|
{
|
|
|
|
|
uint8_t addr; /* Endpoint address */
|
|
|
|
|
bool in; /* Direction: true->IN */
|
|
|
|
|
uint8_t funcaddr; /* USB address of function containing endpoint */
|
2012-08-20 16:06:39 +00:00
|
|
|
uint8_t xfrtype; /* Transfer type. See USB_EP_ATTR_XFER_* in usb.h */
|
2011-01-16 14:02:42 +00:00
|
|
|
uint8_t interval; /* Polling interval */
|
2011-01-11 01:41:06 +00:00
|
|
|
uint16_t mxpacketsize; /* Max packetsize */
|
|
|
|
|
};
|
|
|
|
|
|
2012-08-20 13:55:19 +00:00
|
|
|
/* This type represents one endpoint configured by the epalloc() method.
|
2011-01-11 01:41:06 +00:00
|
|
|
* The actual form is know only internally to the USB host controller
|
|
|
|
|
* (for example, for an OHCI driver, this would probably be a pointer
|
|
|
|
|
* to an endpoint descriptor).
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
typedef FAR void *usbhost_ep_t;
|
|
|
|
|
|
2013-08-13 15:03:46 -06:00
|
|
|
/* struct usbhost_connection_s provides as interface between platform-specific
|
|
|
|
|
* connection monitoring and the USB host driver connectin and enumeration
|
|
|
|
|
* logic.
|
2010-12-15 03:12:09 +00:00
|
|
|
*/
|
|
|
|
|
|
2013-08-13 15:03:46 -06:00
|
|
|
struct usbhost_connection_s
|
2010-12-15 03:12:09 +00:00
|
|
|
{
|
2010-12-31 17:25:24 +00:00
|
|
|
/* Wait for a device to connect or disconnect. */
|
2010-12-21 01:41:03 +00:00
|
|
|
|
2013-08-13 17:43:19 -06:00
|
|
|
int (*wait)(FAR struct usbhost_connection_s *conn, FAR const bool *connected);
|
2010-12-21 01:41:03 +00:00
|
|
|
|
2013-08-12 14:44:06 -06:00
|
|
|
/* Enumerate the device connected on a root hub port. As part of this
|
|
|
|
|
* enumeration process, the driver will (1) get the device's configuration
|
|
|
|
|
* descriptor, (2) extract the class ID info from the configuration
|
|
|
|
|
* descriptor, (3) call usbhost_findclass() to find the class that supports
|
|
|
|
|
* this device, (4) call the create() method on the struct usbhost_registry_s
|
|
|
|
|
* interface to get a class instance, and finally (5) call the connect()
|
|
|
|
|
* method of the struct usbhost_class_s interface. After that, the class is
|
|
|
|
|
* in charge of the sequence of operations.
|
2010-12-16 02:06:24 +00:00
|
|
|
*/
|
2010-12-15 03:12:09 +00:00
|
|
|
|
2013-08-13 17:43:19 -06:00
|
|
|
int (*enumerate)(FAR struct usbhost_connection_s *conn, int rhpndx);
|
2013-08-13 15:03:46 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* struct usbhost_driver_s provides access to the USB host driver from the
|
|
|
|
|
* USB host class implementation.
|
|
|
|
|
*/
|
2010-12-15 03:12:09 +00:00
|
|
|
|
2013-08-13 15:03:46 -06:00
|
|
|
struct usbhost_driver_s
|
|
|
|
|
{
|
2010-12-28 02:22:11 +00:00
|
|
|
/* Configure endpoint 0. This method is normally used internally by the
|
|
|
|
|
* enumerate() method but is made available at the interface to support
|
|
|
|
|
* an external implementation of the enumeration logic.
|
|
|
|
|
*/
|
|
|
|
|
|
2011-01-01 15:08:18 +00:00
|
|
|
int (*ep0configure)(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr,
|
2010-12-28 02:22:11 +00:00
|
|
|
uint16_t maxpacketsize);
|
|
|
|
|
|
2011-01-11 01:41:06 +00:00
|
|
|
/* Allocate and configure an endpoint. */
|
|
|
|
|
|
|
|
|
|
int (*epalloc)(FAR struct usbhost_driver_s *drvr,
|
|
|
|
|
const FAR struct usbhost_epdesc_s *epdesc, usbhost_ep_t *ep);
|
|
|
|
|
int (*epfree)(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep);
|
|
|
|
|
|
2010-12-17 02:19:04 +00:00
|
|
|
/* Some hardware supports special memory in which transfer descriptors can
|
|
|
|
|
* be accessed more efficiently. The following methods provide a mechanism
|
|
|
|
|
* to allocate and free the transfer descriptor memory. If the underlying
|
|
|
|
|
* hardware does not support such "special" memory, these functions may
|
2012-08-21 20:14:42 +00:00
|
|
|
* simply map to kmalloc and kfree.
|
2011-03-25 22:56:36 +00:00
|
|
|
*
|
|
|
|
|
* This interface was optimized under a particular assumption. It was assumed
|
|
|
|
|
* that the driver maintains a pool of small, pre-allocated buffers for descriptor
|
|
|
|
|
* traffic. NOTE that size is not an input, but an output: The size of the
|
|
|
|
|
* pre-allocated buffer is returned.
|
2010-12-16 02:06:24 +00:00
|
|
|
*/
|
2010-12-15 03:12:09 +00:00
|
|
|
|
2010-12-17 02:19:04 +00:00
|
|
|
int (*alloc)(FAR struct usbhost_driver_s *drvr,
|
|
|
|
|
FAR uint8_t **buffer, FAR size_t *maxlen);
|
|
|
|
|
int (*free)(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer);
|
2010-12-15 03:12:09 +00:00
|
|
|
|
2011-03-25 22:56:36 +00:00
|
|
|
/* Some hardware supports special memory in which larger IO buffers can
|
|
|
|
|
* be accessed more efficiently. This method provides a mechanism to allocate
|
|
|
|
|
* the request/descriptor memory. If the underlying hardware does not support
|
2012-08-21 20:14:42 +00:00
|
|
|
* such "special" memory, this functions may simply map to kmalloc.
|
2011-03-25 22:56:36 +00:00
|
|
|
*
|
|
|
|
|
* This interface differs from DRVR_ALLOC in that the buffers are variable-sized.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
int (*ioalloc)(FAR struct usbhost_driver_s *drvr,
|
|
|
|
|
FAR uint8_t **buffer, size_t buflen);
|
|
|
|
|
int (*iofree)(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer);
|
|
|
|
|
|
2010-12-20 16:51:15 +00:00
|
|
|
/* Process a IN or OUT request on the control endpoint. These methods
|
2010-12-20 20:59:12 +00:00
|
|
|
* will enqueue the request and wait for it to complete. Only one transfer may
|
|
|
|
|
* be queued; Neither these methods nor the transfer() method can be called again
|
2010-12-20 16:51:15 +00:00
|
|
|
* until the control transfer functions returns.
|
|
|
|
|
*
|
|
|
|
|
* These are blocking methods; these functions will not return until the
|
|
|
|
|
* control transfer has completed.
|
2010-12-18 03:24:13 +00:00
|
|
|
*/
|
|
|
|
|
|
2010-12-20 16:51:15 +00:00
|
|
|
int (*ctrlin)(FAR struct usbhost_driver_s *drvr,
|
|
|
|
|
FAR const struct usb_ctrlreq_s *req,
|
|
|
|
|
FAR uint8_t *buffer);
|
|
|
|
|
int (*ctrlout)(FAR struct usbhost_driver_s *drvr,
|
|
|
|
|
FAR const struct usb_ctrlreq_s *req,
|
|
|
|
|
FAR const uint8_t *buffer);
|
|
|
|
|
|
|
|
|
|
/* Process a request to handle a transfer descriptor. This method will
|
2010-12-20 20:59:12 +00:00
|
|
|
* enqueue the transfer request and wait for it to complete. Only one transfer may
|
|
|
|
|
* be queued; Neither this method nor the ctrlin or ctrlout methods can be called
|
2010-12-20 16:51:15 +00:00
|
|
|
* again until this function returns.
|
|
|
|
|
*
|
|
|
|
|
* This is a blocking method; this functions will not return until the
|
|
|
|
|
* transfer has completed.
|
2010-12-18 03:24:13 +00:00
|
|
|
*/
|
2010-12-15 03:12:09 +00:00
|
|
|
|
2011-01-11 01:41:06 +00:00
|
|
|
int (*transfer)(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep,
|
2010-12-18 03:24:13 +00:00
|
|
|
FAR uint8_t *buffer, size_t buflen);
|
2010-12-18 17:35:54 +00:00
|
|
|
|
|
|
|
|
/* Called by the class when an error occurs and driver has been disconnected.
|
|
|
|
|
* The USB host driver should discard the handle to the class instance (it is
|
|
|
|
|
* stale) and not attempt any further interaction with the class driver instance
|
|
|
|
|
* (until a new instance is received from the create() method).
|
|
|
|
|
*/
|
|
|
|
|
|
2013-08-13 14:12:27 -06:00
|
|
|
void (*disconnect)(FAR struct usbhost_driver_s *drvr);
|
2010-12-15 22:28:35 +00:00
|
|
|
};
|
|
|
|
|
|
2008-10-22 16:20:18 +00:00
|
|
|
/************************************************************************************
|
|
|
|
|
* Public Data
|
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
2010-12-14 15:24:50 +00:00
|
|
|
#undef EXTERN
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
|
#define EXTERN extern "C"
|
2013-08-12 14:44:06 -06:00
|
|
|
extern "C"
|
|
|
|
|
{
|
2010-12-14 15:24:50 +00:00
|
|
|
#else
|
|
|
|
|
#define EXTERN extern
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-01-26 19:37:34 +00:00
|
|
|
/************************************************************************************
|
|
|
|
|
* Public Functions
|
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
2010-12-14 15:24:50 +00:00
|
|
|
/************************************************************************************
|
|
|
|
|
* Name: usbhost_registerclass
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* Register a USB host class implementation. The caller provides an instance of
|
|
|
|
|
* struct usbhost_registry_s that contains all of the information that will be
|
|
|
|
|
* needed later to (1) associate the USB host class implementation with a connected
|
|
|
|
|
* USB device, and (2) to obtain and bind a struct usbhost_class_s instance for
|
|
|
|
|
* the device.
|
|
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* class - An write-able instance of struct usbhost_registry_s that will be
|
|
|
|
|
* maintained in a registry.
|
|
|
|
|
*
|
|
|
|
|
* Returned Values:
|
|
|
|
|
* On success, this function will return zero (OK). Otherwise, a negated errno
|
|
|
|
|
* value is returned.
|
|
|
|
|
*
|
2008-10-22 16:20:18 +00:00
|
|
|
************************************************************************************/
|
|
|
|
|
|
2013-08-12 14:44:06 -06:00
|
|
|
int usbhost_registerclass(struct usbhost_registry_s *class);
|
2010-12-14 15:24:50 +00:00
|
|
|
|
2008-10-22 16:20:18 +00:00
|
|
|
/************************************************************************************
|
2010-12-14 15:24:50 +00:00
|
|
|
* Name: usbhost_findclass
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* Find a USB host class implementation previously registered by
|
|
|
|
|
* usbhost_registerclass(). On success, an instance of struct usbhost_registry_s
|
|
|
|
|
* will be returned. That instance will contain all of the information that will
|
|
|
|
|
* be needed to obtain and bind a struct usbhost_class_s instance for the device.
|
|
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* id - Identifies the USB device class that has connect to the USB host.
|
|
|
|
|
*
|
|
|
|
|
* Returned Values:
|
|
|
|
|
* On success this function will return a non-NULL instance of struct
|
|
|
|
|
* usbhost_registry_s. NULL will be returned on failure. This function can only
|
|
|
|
|
* fail if (1) id is NULL, or (2) no USB host class is registered that matches the
|
|
|
|
|
* device class ID.
|
|
|
|
|
*
|
2008-10-22 16:20:18 +00:00
|
|
|
************************************************************************************/
|
|
|
|
|
|
2013-08-12 14:44:06 -06:00
|
|
|
const struct usbhost_registry_s *usbhost_findclass(const struct usbhost_id_s *id);
|
2010-12-14 15:24:50 +00:00
|
|
|
|
2010-12-14 16:35:10 +00:00
|
|
|
/****************************************************************************
|
|
|
|
|
* Name: usbhost_storageinit
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* Initialize the USB host storage class. This function should be called
|
|
|
|
|
* be platform-specific code in order to initialize and register support
|
|
|
|
|
* for the USB host storage class.
|
|
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* None
|
|
|
|
|
*
|
|
|
|
|
* Returned Values:
|
|
|
|
|
* On success this function will return zero (OK); A negated errno value
|
|
|
|
|
* will be returned on failure.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2013-08-12 14:44:06 -06:00
|
|
|
int usbhost_storageinit(void);
|
2010-12-14 16:35:10 +00:00
|
|
|
|
2011-01-15 22:30:23 +00:00
|
|
|
/****************************************************************************
|
|
|
|
|
* Name: usbhost_kbdinit
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* Initialize the USB storage HID keyboard class driver. This function
|
|
|
|
|
* should be called be platform-specific code in order to initialize and
|
|
|
|
|
* register support for the USB host HID keyboard class device.
|
|
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* None
|
|
|
|
|
*
|
|
|
|
|
* Returned Values:
|
|
|
|
|
* On success this function will return zero (OK); A negated errno value
|
|
|
|
|
* will be returned on failure.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2013-08-12 14:44:06 -06:00
|
|
|
int usbhost_kbdinit(void);
|
2011-01-15 22:30:23 +00:00
|
|
|
|
2011-02-12 19:17:37 +00:00
|
|
|
/****************************************************************************
|
|
|
|
|
* Name: usbhost_wlaninit
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* Initialize the USB WLAN class driver. This function should be called
|
|
|
|
|
* be platform-specific code in order to initialize and register support
|
|
|
|
|
* for the USB host class device.
|
|
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* None
|
|
|
|
|
*
|
|
|
|
|
* Returned Values:
|
|
|
|
|
* On success this function will return zero (OK); A negated errno value
|
|
|
|
|
* will be returned on failure.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2013-08-12 14:44:06 -06:00
|
|
|
int usbhost_wlaninit(void);
|
2011-02-12 19:17:37 +00:00
|
|
|
|
2010-12-28 02:22:11 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
|
* Name: usbhost_enumerate
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* This is a share-able implementation of most of the logic required by the
|
|
|
|
|
* driver enumerate() method. This logic within this method should be common
|
|
|
|
|
* to all USB host drivers.
|
|
|
|
|
*
|
|
|
|
|
* Enumerate the connected device. As part of this enumeration process,
|
|
|
|
|
* the driver will (1) get the device's configuration descriptor, (2)
|
|
|
|
|
* extract the class ID info from the configuration descriptor, (3) call
|
|
|
|
|
* usbhost_findclass() to find the class that supports this device, (4)
|
|
|
|
|
* call the create() method on the struct usbhost_registry_s interface
|
|
|
|
|
* to get a class instance, and finally (5) call the configdesc() method
|
|
|
|
|
* of the struct usbhost_class_s interface. After that, the class is in
|
|
|
|
|
* charge of the sequence of operations.
|
|
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* drvr - The USB host driver instance obtained as a parameter from the call to
|
|
|
|
|
* the class create() method.
|
2011-01-02 20:05:28 +00:00
|
|
|
* funcaddr - The USB address of the function containing the endpoint that EP0
|
|
|
|
|
* controls
|
2010-12-28 02:22:11 +00:00
|
|
|
* class - If the class driver for the device is successful located
|
|
|
|
|
* and bound to the driver, the allocated class instance is returned into
|
|
|
|
|
* this caller-provided memory location.
|
|
|
|
|
*
|
|
|
|
|
* Returned Values:
|
|
|
|
|
* On success, zero (OK) is returned. On a failure, a negated errno value is
|
|
|
|
|
* returned indicating the nature of the failure
|
|
|
|
|
*
|
|
|
|
|
* Assumptions:
|
|
|
|
|
* - Only a single class bound to a single device is supported.
|
|
|
|
|
* - Called from a single thread so no mutual exclusion is required.
|
|
|
|
|
* - Never called from an interrupt handler.
|
|
|
|
|
*
|
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
2013-08-12 14:44:06 -06:00
|
|
|
int usbhost_enumerate(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr,
|
|
|
|
|
FAR struct usbhost_class_s **class);
|
2010-12-28 02:22:11 +00:00
|
|
|
|
2010-12-14 15:24:50 +00:00
|
|
|
#undef EXTERN
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-07-17 03:58:11 +00:00
|
|
|
#endif /* __INCLUDE_NUTTX_USB_USBHOST_H */
|