Resync new repository with old repo r5166

git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5153 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2012-09-17 18:18:44 +00:00
commit 57623d42eb
5691 changed files with 1361853 additions and 0 deletions
+92
View File
@@ -0,0 +1,92 @@
#
# For a description of the syntax of this configuration file,
# see misc/tools/kconfig-language.txt.
#
config USBHOST_NPREALLOC
int "Number of pre-allocated class instances"
default 4
---help---
Number of pre-allocated class instances
config USBHOST_BULK_DISABLE
bool "Disable bulk endpoint support"
default n
---help---
On some architectures, selecting this setting will reduce driver size
by disabling bulk endpoint support
config USBHOST_INT_DISABLE
bool "Disable interrupt endpoint support"
default n
---help---
On some architectures, selecting this setting will reduce driver size
by disabling interrupt endpoint support
config USBHOST_ISOC_DISABLE
bool "Disable isochronous endpoint support"
default n
---help---
On some architectures, selecting this setting will reduce driver size
by disabling isochronous endpoint support
config USBHOST_HIDKBD
bool "HID keyboad class support"
default n
depends on !USBHOST_INT_DISABLE && SCHED_WORKQUEUE && !DISABLE_SIGNALS
if USBHOST_HIDKBD
config HIDKBD_POLLUSEC
bool ""
default n
---help---
Device poll rate in microseconds. Default: 100 milliseconds.
config HIDKBD_DEFPRIO
bool ""
default n
---help---
Priority of the polling thread. Default: 50.
config HIDKBD_STACKSIZE
bool ""
default n
---help---
Stack size for polling thread. Default: 1024
config HIDKBD_BUFSIZE
bool ""
default n
---help---
Scancode buffer size. Default: 64.
config HIDKBD_NPOLLWAITERS
bool ""
default n
---help---
If the poll() method is enabled, this defines the maximum number
of threads that can be waiting for keyboard events. Default: 2.
config HIDKBD_RAWSCANCODES
bool ""
default n
---help---
If set to y no conversion will be made on the raw keyboard scan
codes. Default: ASCII conversion.
config HIDKBD_ALLSCANCODES
bool ""
default n
---help---
If set to y all 231 possible scancodes will be converted to
something. Default: 104 key US keyboard.
config HIDKBD_NODEBOUNCE
bool ""
default n
---help---
If set to y normal debouncing is disabled. Default:
Debounce enabled (No repeat keys).
USB host mass storage class driver. Requires USBHOST=y,
config USBHOST_BULK_DISABLE=n, NFILE_DESCRIPTORS > 0,
and SCHED_WORKQUEUE=y
endif
+57
View File
@@ -0,0 +1,57 @@
############################################################################
# drivers/usbhost/Make.defs
#
# Copyright (C) 2010-2011 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# 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.
#
############################################################################
CSRCS += hid_parser.c
ifeq ($(CONFIG_USBHOST),y)
# Include built-in USB host driver logic
CSRCS += usbhost_registry.c usbhost_registerclass.c usbhost_findclass.c
CSRCS += usbhost_enumerate.c usbhost_storage.c usbhost_hidkbd.c
# Include add-on USB host driver logic (see misc/drivers)
ifeq ($(CONFIG_NET),y)
RTL8187_CSRC := ${shell if [ -f usbhost/rtl8187x.c ]; then echo "rtl8187x.c"; fi}
CSRCS += $(RTL8187_CSRC)
endif
endif
# Include USB host driver build logic
DEPPATH += --dep-path usbhost
VPATH += :usbhost
CFLAGS += ${shell $(TOPDIR)/tools/incdir.sh $(INCDIROPT) "$(CC)" $(TOPDIR)/drivers/usbhost}
+529
View File
@@ -0,0 +1,529 @@
/****************************************************************************
* drivers/usbhost/hid_parser.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
*
* Adapted from the LUFA Library:
*
* Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
* dean [at] fourwalledcubicle [dot] com, www.lufa-lib.org
*
* Permission to use, copy, modify, distribute, and sell this
* software and its documentation for any purpose is hereby granted
* without fee, provided that the above copyright notice appear in
* all copies and that both that the copyright notice and this
* permission notice and warranty disclaimer appear in supporting
* documentation, and that the name of the author not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
*
* The author disclaim all warranties with regard to this
* software, including all implied warranties of merchantability
* and fitness. In no event shall the author be liable for any
* special, indirect or consequential damages or any damages
* whatsoever resulting from loss of use, data or profits, whether
* in an action of contract, negligence or other tortious action,
* arising out of or in connection with the use or performance of
* this software.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <assert.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/usb/hid.h>
#include <nuttx/usb/hid_parser.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
struct hid_state_s
{
struct hid_rptitem_attributes_s attrib;
uint8_t rptcount;
uint8_t id;
};
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: hid_parsereport
*
* Description:
* Function to process a given HID report returned from an attached device,
* and store it into a given struct hid_rptinfo_s structure.
*
* Input Parameters:
* report Buffer containing the device's HID report table.
* rptlen Size in bytes of the HID report table.
* filter Callback function to decide if an item should be retained
* rptinfo Pointer to a struct hid_rptinfo_s instance for the parser output.
*
* Returned Value:
* Zero on success, otherwise a negated errno value.
****************************************************************************/
int hid_parsereport(FAR const uint8_t *report, int rptlen,
hid_rptfilter_t filter, FAR struct hid_rptinfo_s *rptinfo)
{
struct hid_state_s state[CONFIG_HID_STATEDEPTH];
struct hid_state_s *currstate = &state[0];
struct hid_collectionpath_s *collectionpath = NULL;
struct hid_rptsizeinfo_s *rptidinfo = &rptinfo->rptsize[0];
uint16_t usage[CONFIG_HID_USAGEDEPTH];
uint8_t nusage = 0;
struct hid_range_s usage_range = { 0, 0 };
int i;
DEBUGASSERT(report && filter && rptinfo);
memset(rptinfo, 0x00, sizeof(struct hid_rptinfo_s));
memset(currstate, 0x00, sizeof(struct hid_state_s));
memset(rptidinfo, 0x00, sizeof(struct hid_rptsizeinfo_s));
rptinfo->nreports = 1;
while (rptlen > 0)
{
uint8_t item = *report;
uint32_t data = 0;
report++;
rptlen--;
switch (item & USBHID_RPTITEM_SIZE_MASK)
{
case USBHID_RPTITEM_SIZE_4: /* 4 bytes of little endian data follow */
data = (uint32_t)(*report++);
data |= (uint32_t)(*report++) << 8;
data |= (uint32_t)(*report++) << 16;
data |= (uint32_t)(*report++) << 24;
rptlen -= 4;
break;
case USBHID_RPTITEM_SIZE_2: /* 2 bytes of little endian data follow */
data = (uint32_t)(*report++);
data |= (uint32_t)(*report++) << 8;
rptlen -= 2;
break;
case USBHID_RPTITEM_SIZE_1: /* 1 byte of data follows */
data = (uint32_t)(*report++);
rptlen -= 1;
break;
case USBHID_RPTITEM_SIZE_0: /* No data follows */
default:
break;
}
switch (item & ~USBHID_RPTITEM_SIZE_MASK)
{
case USBHID_GLOBAL_PUSH_PREFIX:
if (currstate == &state[CONFIG_HID_STATEDEPTH - 1])
{
return -E2BIG;
}
memcpy((currstate + 1),
currstate, sizeof(struct hid_rptitem_s));
currstate++;
break;
case USBHID_GLOBAL_POP_PREFIX:
if (currstate == &state[0])
{
return -EINVAL; /* Pop without push? */
}
currstate--;
break;
case USBHID_GLOBAL_USAGEPAGE_PREFIX:
if ((item & USBHID_RPTITEM_SIZE_MASK) == USBHID_RPTITEM_SIZE_4)
{
currstate->attrib.usage.page = (data >> 16);
}
currstate->attrib.usage.page = data;
break;
case USBHID_GLOBAL_LOGICALMIN_PREFIX:
currstate->attrib.logical.min = data;
break;
case USBHID_GLOBAL_LOGICALMAX_PREFIX:
currstate->attrib.logical.max = data;
break;
case USBHID_GLOBAL_PHYSICALMIN_PREFIX:
currstate->attrib.physical.min = data;
break;
case USBHID_GLOBAL_PHYSMICALAX_PREFIX:
currstate->attrib.physical.max = data;
break;
case USBHID_GLOBAL_UNITEXP_PREFIX:
currstate->attrib.unit.exponent = data;
break;
case USBHID_GLOBAL_UNIT_PREFIX:
currstate->attrib.unit.type = data;
break;
case USBHID_GLOBAL_REPORTSIZE_PREFIX:
currstate->attrib.bitsize = data;
break;
case USBHID_GLOBAL_REPORTCOUNT_PREFIX:
currstate->rptcount = data;
break;
case USBHID_GLOBAL_REPORTID_PREFIX:
currstate->id = data;
if (rptinfo->haverptid)
{
rptidinfo = NULL;
for (i = 0; i < rptinfo->nreports; i++)
{
if (rptinfo->rptsize[i].id == currstate->id)
{
rptidinfo = &rptinfo->rptsize[i];
break;
}
}
if (rptidinfo == NULL)
{
if (rptinfo->nreports == CONFIG_HID_MAXIDS)
{
return -EINVAL;
}
rptidinfo = &rptinfo->rptsize[rptinfo->nreports++];
memset(rptidinfo, 0x00, sizeof(struct hid_rptsizeinfo_s));
}
}
rptinfo->haverptid = true;
rptidinfo->id = currstate->id;
break;
case USBHID_LOCAL_USAGE_PREFIX:
if (nusage == CONFIG_HID_USAGEDEPTH)
{
return -E2BIG;
}
usage[nusage++] = data;
break;
case USBHID_LOCAL_USAGEMIN_PREFIX:
usage_range.min = data;
break;
case USBHID_LOCAL_USAGEMAX_PREFIX:
usage_range.max = data;
break;
case USBHID_MAIN_COLLECTION_PREFIX:
if (collectionpath == NULL)
{
collectionpath = &rptinfo->collectionpaths[0];
}
else
{
struct hid_collectionpath_s *ParentCollectionPath = collectionpath;
collectionpath = &rptinfo->collectionpaths[1];
while (collectionpath->parent != NULL)
{
if (collectionpath == &rptinfo->collectionpaths[CONFIG_HID_MAXCOLLECTIONS - 1])
{
return -EINVAL;
}
collectionpath++;
}
collectionpath->parent = ParentCollectionPath;
}
collectionpath->type = data;
collectionpath->usage.page = currstate->attrib.usage.page;
if (nusage)
{
collectionpath->usage.usage = usage[0];
for (i = 0; i < nusage; i++)
usage[i] = usage[i + 1];
nusage--;
}
else if (usage_range.min <= usage_range.max)
{
collectionpath->usage.usage = usage_range.min++;
}
break;
case USBHID_MAIN_ENDCOLLECTION_PREFIX:
if (collectionpath == NULL)
{
return -EINVAL;
}
collectionpath = collectionpath->parent;
break;
case USBHID_MAIN_INPUT_PREFIX:
case USBHID_MAIN_OUTPUT_PREFIX:
case USBHID_MAIN_FEATURE_PREFIX:
{
int itemno;
for (itemno = 0; itemno < currstate->rptcount; itemno++)
{
struct hid_rptitem_s newitem;
uint8_t tag;
memcpy(&newitem.attrib, &currstate->attrib,
sizeof(struct hid_rptitem_attributes_s));
newitem.flags = data;
newitem.collectionpath = collectionpath;
newitem.id = currstate->id;
if (nusage)
{
newitem.attrib.usage.usage = usage[0];
for (i = 0; i < nusage; i++)
{
usage[i] = usage[i + 1];
}
nusage--;
}
else if (usage_range.min <= usage_range.max)
{
newitem.attrib.usage.usage = usage_range.min++;
}
tag = (item & ~USBHID_RPTITEM_SIZE_MASK);
if (tag == USBHID_MAIN_INPUT_PREFIX)
{
newitem.type = HID_REPORT_ITEM_IN;
}
else if (tag == USBHID_MAIN_OUTPUT_PREFIX)
{
newitem.type = HID_REPORT_ITEM_OUT;
}
else
{
newitem.type = HID_REPORT_ITEM_FEATURE;
}
newitem.bitoffset = rptidinfo->size[newitem.type];
rptidinfo->size[newitem.type] += currstate->attrib.bitsize;
/* Accumulate the maximum report size */
if (rptinfo->maxrptsize < newitem.bitoffset)
{
rptinfo->maxrptsize = newitem.bitoffset;
}
if ((data & USBHID_MAIN_CONSTANT) == 0 && filter(&newitem))
{
if (rptinfo->nitems == CONFIG_HID_MAXITEMS)
{
return -EINVAL;
}
memcpy(&rptinfo->items[rptinfo->nitems],
&newitem, sizeof(struct hid_rptitem_s));
rptinfo->nitems++;
}
}
}
break;
}
if ((item & USBHID_RPTITEM_TYPE_MASK) == USBHID_RPTITEM_TYPE_MAIN)
{
usage_range.min = 0;
usage_range.max = 0;
nusage = 0;
}
}
if (!(rptinfo->nitems))
{
return -ENOENT;
}
return OK;
}
/****************************************************************************
* Name: hid_getitem
*
* Description:
* Extracts the given report item's value out of the given HID report and
* places it into the value member of the report item's struct hid_rptitem_s
* structure.
*
* When called on a report with an item that exists in that report, this
* copies the report item's Value to it's previous element for easy
* checking to see if an item's value has changed before processing a
* report. If the given item does not exist in the report, the function
* does not modify the report item's data.
*
* Input Parameters
* report Buffer containing an IN or FEATURE report from an attached
* device.
* item Pointer to the report item of interest in a struct hid_rptinfo_s
* item array.
*
* Returned Value:
* Zero on success, otherwise a negated errno value.
*
****************************************************************************/
int hid_getitem(FAR const uint8_t *report, FAR struct hid_rptitem_s *item)
{
uint16_t remaining = item->attrib.bitsize;
uint16_t offset = item->bitoffset;
uint32_t mask = (1 << 0);
if (item->id)
{
if (item->id != report[0])
{
return -ENOENT;
}
report++;
}
item->previous = item->value;
item->value = 0;
while (remaining--)
{
if (report[offset >> 3] & (1 << (offset & 7)))
{
item->value |= mask;
}
offset++;
mask <<= 1;
}
return OK;
}
/****************************************************************************
* Name: hid_putitem
*
* Desription:
* Retrieves the given report item's value out of the Value member of the
* report item's struct hid_rptitem_s structure and places it into the correct
* position in the HID report buffer. The report buffer is assumed to have
* the appropriate bits cleared before calling this function (i.e., the
* buffer should be explicitly cleared before report values are added).
*
* When called, this copies the report item's Value element to it's
* previous element for easy checking to see if an item's value has
* changed before sending a report.
*
* If the device has multiple HID reports, the first byte in the report is
* set to the report ID of the given item.
*
* Input Parameters:
* report Buffer holding the current OUT or FEATURE report data.
* item Pointer to the report item of interest in a struct hid_rptinfo_s
* item array.
*
****************************************************************************/
#if 0 /* Not needed by host */
void hid_putitem(FAR uint8_t *report, struct hid_rptitem_s *item)
{
uint16_t remaining = item->attrib.bitsize;
uint16_t offset = item->bitoffset;
uint32_t mask = (1 << 0);
if (item->id)
{
report[0] = item->id;
report++;
}
item->previous = item->value;
while (remaining--)
{
if (item->value & (1 << (offset & 7)))
{
report[offset >> 3] |= mask;
}
offset++;
mask <<= 1;
}
}
#endif
/****************************************************************************
* Name: hid_reportsize
*
* Description:
* Retrieves the size of a given HID report in bytes from it's Report ID.
*
* InputParameters:
* rptinfo Pointer to a struct hid_rptinfo_s instance containing the parser output.
* id Report ID of the report whose size is to be retrieved.
* rpttype Type of the report whose size is to be determined, a valued from the
* HID_ReportItemTypes_t enum.
*
* Size of the report in bytes, or 0 if the report does not exist.
*
****************************************************************************/
size_t hid_reportsize(FAR struct hid_rptinfo_s *rptinfo, uint8_t id, uint8_t rpttype)
{
int i;
for (i = 0; i < CONFIG_HID_MAXIDS; i++)
{
size_t size = rptinfo->rptsize[i].size[rpttype];
if (rptinfo->rptsize[i].id == id)
{
return ((size >> 3) + ((size & 0x07) ? 1 : 0));
}
}
return 0;
}
+518
View File
@@ -0,0 +1,518 @@
/*******************************************************************************
* drivers/usbhost/usbhost_enumerate.c
*
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
*
* 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.
*
*******************************************************************************/
/*******************************************************************************
* Included Files
*******************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/usb/usb.h>
#include <nuttx/usb/usbhost.h>
/*******************************************************************************
* Definitions
*******************************************************************************/
/*******************************************************************************
* Private Types
*******************************************************************************/
/*******************************************************************************
* Private Function Prototypes
*******************************************************************************/
static inline uint16_t usbhost_getle16(const uint8_t *val);
static void usbhost_putle16(uint8_t *dest, uint16_t val);
static inline int usbhost_devdesc(const struct usb_devdesc_s *devdesc,
struct usbhost_id_s *id);
static inline int usbhost_configdesc(const uint8_t *configdesc, int desclen,
struct usbhost_id_s *id);
static inline int usbhost_classbind(FAR struct usbhost_driver_s *drvr,
const uint8_t *configdesc, int desclen,
struct usbhost_id_s *id, uint8_t funcaddr,
FAR struct usbhost_class_s **class);
/*******************************************************************************
* Private Data
*******************************************************************************/
/*******************************************************************************
* Public Data
*******************************************************************************/
/*******************************************************************************
* Private Functions
*******************************************************************************/
/****************************************************************************
* Name: usbhost_getle16
*
* Description:
* Get a (possibly unaligned) 16-bit little endian value.
*
*******************************************************************************/
static inline uint16_t usbhost_getle16(const uint8_t *val)
{
return (uint16_t)val[1] << 8 | (uint16_t)val[0];
}
/****************************************************************************
* Name: usbhost_putle16
*
* Description:
* Put a (possibly unaligned) 16-bit little endian value.
*
*******************************************************************************/
static void usbhost_putle16(uint8_t *dest, uint16_t val)
{
dest[0] = val & 0xff; /* Little endian means LS byte first in byte stream */
dest[1] = val >> 8;
}
/*******************************************************************************
* Name: usbhost_devdesc
*
* Description:
* A configuration descriptor has been obtained from the device. Find the
* ID information for the class that supports this device.
*
*******************************************************************************/
static inline int usbhost_devdesc(FAR const struct usb_devdesc_s *devdesc,
FAR struct usbhost_id_s *id)
{
/* Clear the ID info */
memset(id, 0, sizeof(struct usbhost_id_s));
/* Pick off the class ID info */
id->base = devdesc->classid;
id->subclass = devdesc->subclass;
id->proto = devdesc->protocol;
/* Pick off the VID and PID as well (for vendor specfic devices) */
id->vid = usbhost_getle16(devdesc->vendor);
id->pid = usbhost_getle16(devdesc->product);
uvdbg("class:%d subclass:%04x protocol:%04x vid:%d pid:%d\n",
id->base, id->subclass, id->proto, id->vid, id->pid);
return OK;
}
/*******************************************************************************
* Name: usbhost_configdesc
*
* Description:
* A configuration descriptor has been obtained from the device. Find the
* ID information for the class that supports this device.
*
*******************************************************************************/
static inline int usbhost_configdesc(const uint8_t *configdesc, int cfglen,
struct usbhost_id_s *id)
{
struct usb_cfgdesc_s *cfgdesc;
struct usb_ifdesc_s *ifdesc;
int remaining;
DEBUGASSERT(configdesc != NULL && cfglen >= USB_SIZEOF_CFGDESC);
/* Verify that we were passed a configuration descriptor */
cfgdesc = (struct usb_cfgdesc_s *)configdesc;
uvdbg("cfg len:%d total len:%d\n", cfgdesc->len, cfglen);
if (cfgdesc->type != USB_DESC_TYPE_CONFIG)
{
return -EINVAL;
}
/* Skip to the next entry descriptor */
configdesc += cfgdesc->len;
remaining = cfglen - cfgdesc->len;
/* Loop where there are more dscriptors to examine */
memset(id, 0, sizeof(FAR struct usb_desc_s));
while (remaining >= sizeof(struct usb_desc_s))
{
/* What is the next descriptor? Is it an interface descriptor? */
ifdesc = (struct usb_ifdesc_s *)configdesc;
if (ifdesc->type == USB_DESC_TYPE_INTERFACE)
{
/* Yes, extract the class information from the interface descriptor.
* Typically these values are zero meaning that the "real" ID
* information resides in the device descriptor.
*/
DEBUGASSERT(remaining >= sizeof(struct usb_ifdesc_s));
id->base = ifdesc->classid;
id->subclass = ifdesc->subclass;
id->proto = ifdesc->protocol;
uvdbg("class:%d subclass:%d protocol:%d\n",
id->base, id->subclass, id->proto);
return OK;
}
/* Increment the address of the next descriptor */
configdesc += ifdesc->len;
remaining -= ifdesc->len;
}
return -ENOENT;
}
/*******************************************************************************
* Name: usbhost_classbind
*
* Description:
* A configuration descriptor has been obtained from the device. Try to
* bind this configuration descriptor with a supported class.
*
*******************************************************************************/
static inline int usbhost_classbind(FAR struct usbhost_driver_s *drvr,
const uint8_t *configdesc, int desclen,
struct usbhost_id_s *id, uint8_t funcaddr,
FAR struct usbhost_class_s **class)
{
FAR struct usbhost_class_s *devclass;
const struct usbhost_registry_s *reg;
int ret = -EINVAL;
/* Is there is a class implementation registered to support this device. */
reg = usbhost_findclass(id);
uvdbg("usbhost_findclass: %p\n", reg);
if (reg)
{
/* Yes.. there is a class for this device. Get an instance of
* its interface.
*/
ret = -ENOMEM;
devclass = CLASS_CREATE(reg, drvr, id);
uvdbg("CLASS_CREATE: %p\n", devclass);
if (devclass)
{
/* Then bind the newly instantiated class instance */
ret = CLASS_CONNECT(devclass, configdesc, desclen, funcaddr);
if (ret != OK)
{
/* On failures, call the class disconnect method which
* should then free the allocated devclass instance.
*/
udbg("CLASS_CONNECT failed: %d\n", ret);
CLASS_DISCONNECTED(devclass);
}
else
{
*class = devclass;
}
}
}
uvdbg("Returning: %d\n", ret);
return ret;
}
/*******************************************************************************
* Public Functions
*******************************************************************************/
/*******************************************************************************
* Name: usbhost_enumerate
*
* Description:
* 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.
* funcaddr - The USB address of the function containing the endpoint that EP0
* controls
* 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.
*
*******************************************************************************/
int usbhost_enumerate(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr,
FAR struct usbhost_class_s **class)
{
struct usb_ctrlreq_s *ctrlreq;
struct usbhost_id_s id;
size_t maxlen;
unsigned int cfglen;
uint8_t maxpacketsize;
uint8_t *buffer;
int ret;
DEBUGASSERT(drvr && class);
/* Allocate descriptor buffers for use in this function. We will need two:
* One for the request and one for the data buffer.
*/
ret = DRVR_ALLOC(drvr, (FAR uint8_t **)&ctrlreq, &maxlen);
if (ret != OK)
{
udbg("DRVR_ALLOC failed: %d\n", ret);
return ret;
}
ret = DRVR_ALLOC(drvr, &buffer, &maxlen);
if (ret != OK)
{
udbg("DRVR_ALLOC failed: %d\n", ret);
goto errout;
}
/* Set max pkt size = 8 */
DRVR_EP0CONFIGURE(drvr, 0, 8);
/* Read first 8 bytes of the device descriptor */
ctrlreq->type = USB_REQ_DIR_IN|USB_REQ_RECIPIENT_DEVICE;
ctrlreq->req = USB_REQ_GETDESCRIPTOR;
usbhost_putle16(ctrlreq->value, (USB_DESC_TYPE_DEVICE << 8));
usbhost_putle16(ctrlreq->index, 0);
usbhost_putle16(ctrlreq->len, 8);
ret = DRVR_CTRLIN(drvr, ctrlreq, buffer);
if (ret != OK)
{
udbg("ERROR: GETDESCRIPTOR/DEVICE, DRVR_CTRLIN returned %d\n", ret);
goto errout;
}
/* Extract the correct max packetsize from the device descriptor */
maxpacketsize = ((struct usb_devdesc_s *)buffer)->mxpacketsize;
uvdbg("maxpacksetsize: %d\n", maxpacketsize);
/* And reconfigure EP0 */
DRVR_EP0CONFIGURE(drvr, 0, maxpacketsize);
/* Now read the full device descriptor */
ctrlreq->type = USB_REQ_DIR_IN|USB_REQ_RECIPIENT_DEVICE;
ctrlreq->req = USB_REQ_GETDESCRIPTOR;
usbhost_putle16(ctrlreq->value, (USB_DESC_TYPE_DEVICE << 8));
usbhost_putle16(ctrlreq->index, 0);
usbhost_putle16(ctrlreq->len, USB_SIZEOF_DEVDESC);
ret = DRVR_CTRLIN(drvr, ctrlreq, buffer);
if (ret != OK)
{
udbg("ERROR: GETDESCRIPTOR/DEVICE, DRVR_CTRLIN returned %d\n", ret);
goto errout;
}
/* Get class identification information from the device descriptor. Most
* devices set this to USB_CLASS_PER_INTERFACE (zero) and provide the
* identification informatino in the interface descriptor(s). That allows
* a device to support multiple, different classes.
*/
(void)usbhost_devdesc((struct usb_devdesc_s *)buffer, &id);
/* Set the USB device address to the value in the 'funcaddr' input */
ctrlreq->type = USB_REQ_DIR_OUT|USB_REQ_RECIPIENT_DEVICE;
ctrlreq->req = USB_REQ_SETADDRESS;
usbhost_putle16(ctrlreq->value, (uint16_t)funcaddr);
usbhost_putle16(ctrlreq->index, 0);
usbhost_putle16(ctrlreq->len, 0);
ret = DRVR_CTRLOUT(drvr, ctrlreq, NULL);
if (ret != OK)
{
udbg("ERROR: SETADDRESS DRVR_CTRLOUT returned %d\n", ret);
goto errout;
}
usleep(2*1000);
/* Modify control pipe with the provided USB device address */
DRVR_EP0CONFIGURE(drvr, funcaddr, maxpacketsize);
/* Get the configuration descriptor (only), index == 0. Should not be
* hard-coded! More logic is needed in order to handle devices with
* multiple configurations.
*/
ctrlreq->type = USB_REQ_DIR_IN|USB_REQ_RECIPIENT_DEVICE;
ctrlreq->req = USB_REQ_GETDESCRIPTOR;
usbhost_putle16(ctrlreq->value, (USB_DESC_TYPE_CONFIG << 8));
usbhost_putle16(ctrlreq->index, 0);
usbhost_putle16(ctrlreq->len, USB_SIZEOF_CFGDESC);
ret = DRVR_CTRLIN(drvr, ctrlreq, buffer);
if (ret != OK)
{
udbg("ERROR: GETDESCRIPTOR/CONFIG, DRVR_CTRLIN returned %d\n", ret);
goto errout;
}
/* Extract the full size of the configuration data */
cfglen = (unsigned int)usbhost_getle16(((struct usb_cfgdesc_s *)buffer)->totallen);
uvdbg("sizeof config data: %d\n", cfglen);
/* Get all of the configuration descriptor data, index == 0 (Should not be
* hard-coded!)
*/
ctrlreq->type = USB_REQ_DIR_IN|USB_REQ_RECIPIENT_DEVICE;
ctrlreq->req = USB_REQ_GETDESCRIPTOR;
usbhost_putle16(ctrlreq->value, (USB_DESC_TYPE_CONFIG << 8));
usbhost_putle16(ctrlreq->index, 0);
usbhost_putle16(ctrlreq->len, cfglen);
ret = DRVR_CTRLIN(drvr, ctrlreq, buffer);
if (ret != OK)
{
udbg("ERROR: GETDESCRIPTOR/CONFIG, DRVR_CTRLIN returned %d\n", ret);
goto errout;
}
/* Select device configuration 1 (Should not be hard-coded!) */
ctrlreq->type = USB_REQ_DIR_OUT|USB_REQ_RECIPIENT_DEVICE;
ctrlreq->req = USB_REQ_SETCONFIGURATION;
usbhost_putle16(ctrlreq->value, 1);
usbhost_putle16(ctrlreq->index, 0);
usbhost_putle16(ctrlreq->len, 0);
ret = DRVR_CTRLOUT(drvr, ctrlreq, NULL);
if (ret != OK)
{
udbg("ERROR: SETCONFIGURATION, DRVR_CTRLOUT returned %d\n", ret);
goto errout;
}
/* Free the descriptor buffer that we were using for the request buffer.
* It is not needed further here but it may be needed by the class driver
* during its connection operations.
*/
DRVR_FREE(drvr, (uint8_t*)ctrlreq);
ctrlreq = NULL;
/* Was the class identification information provided in the device descriptor?
* Or do we need to find it in the interface descriptor(s)?
*/
if (id.base == USB_CLASS_PER_INTERFACE)
{
/* Get the class identification information for this device from the
* interface descriptor(s). Hmmm.. More logic is need to handle the
* case of multiple interface descriptors.
*/
ret = usbhost_configdesc(buffer, cfglen, &id);
if (ret != OK)
{
udbg("ERROR: usbhost_configdesc returned %d\n", ret);
goto errout;
}
}
/* Some devices may require some delay before initialization */
usleep(100*1000);
/* Parse the configuration descriptor and bind to the class instance for the
* device. This needs to be the last thing done because the class driver
* will begin configuring the device.
*/
ret = usbhost_classbind(drvr, buffer, cfglen, &id, funcaddr, class);
if (ret != OK)
{
udbg("ERROR: usbhost_classbind returned %d\n", ret);
}
errout:
if (buffer)
{
DRVR_FREE(drvr, buffer);
}
if (ctrlreq)
{
DRVR_FREE(drvr, (uint8_t*)ctrlreq);
}
return ret;
}
+199
View File
@@ -0,0 +1,199 @@
/****************************************************************************
* drivers/usbhost/usbhost_findclass.c
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/usb/usb.h>
#include <nuttx/usb/usbhost.h>
#include <arch/irq.h>
#include "usbhost_registry.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: usbhost_idmatch
*
* Description:
* Check if the class ID matches what the host controller found.
*
* Input Parameters:
* classid - ID info for the class under consideration.
* devid - ID info reported by the device.
*
* Returned Values:
* TRUE - the class will support this device.
*
****************************************************************************/
static bool usbhost_idmatch(const struct usbhost_id_s *classid,
const struct usbhost_id_s *devid)
{
uvdbg("Compare to class:%d subclass:%d protocol:%d vid:%04x pid:%04x\n",
classid->base, classid->subclass, classid->proto,
classid->vid, classid->pid);
/* The base class ID, subclass and protocol have to match up in any event */
if (devid->base == classid->base &&
devid->subclass == classid->subclass &&
devid->proto == classid->proto)
{
/* If this is a vendor-specific class ID, then the VID and PID have to
* match as well.
*/
if (devid->base == USB_CLASS_VENDOR_SPEC)
{
/* Vendor specific... do the VID and PID also match? */
if (devid->vid == classid->vid && devid->pid == classid->pid)
{
/* Yes.. then we have a match */
return true;
}
}
else
{
/* Not vendor specific? Then we have a match */
return true;
}
}
/* No match.. not supported */
return false;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* 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.
*
****************************************************************************/
const struct usbhost_registry_s *usbhost_findclass(const struct usbhost_id_s *id)
{
struct usbhost_registry_s *class;
irqstate_t flags;
int ndx;
DEBUGASSERT(id);
uvdbg("Looking for class:%d subclass:%d protocol:%d vid:%04x pid:%04x\n",
id->base, id->subclass, id->proto, id->vid, id->pid);
/* g_classregistry is a singly-linkedlist of class ID information added by
* calls to usbhost_registerclass(). Since this list is accessed from USB
* host controller interrupt handling logic, accesses to this list must be
* protected by disabling interrupts.
*/
flags = irqsave();
/* Examine each register class in the linked list */
for (class = g_classregistry; class; class = class->flink)
{
/* If the registered class supports more than one ID, subclass, or
* protocol, then try each.
*/
uvdbg("Checking class:%p nids:%d\n", class, class->nids);
for (ndx = 0; ndx < class->nids; ndx++)
{
/* Did we find a matching ID? */
if (usbhost_idmatch(&class->id[ndx], id))
{
/* Yes.. restore interrupts and return the class info */
irqrestore(flags);
return class;
}
}
}
/* Not found... restore interrupts and return NULL */
irqrestore(flags);
return NULL;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,117 @@
/****************************************************************************
* drivers/usbhost/usbhost_registerclass.c
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <errno.h>
#include <debug.h>
#include <arch/irq.h>
#include <nuttx/usb/usbhost.h>
#include "usbhost_registry.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* 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.
*
****************************************************************************/
int usbhost_registerclass(struct usbhost_registry_s *class)
{
irqstate_t flags;
uvdbg("Registering class:%p nids:%d\n", class, class->nids);
/* g_classregistry is a singly-linkedlist of class ID information added by
* calls to usbhost_registerclass(). Since this list is accessed from USB
* host controller interrupt handling logic, accesses to this list must be
* protected by disabling interrupts.
*/
flags = irqsave();
/* Add the new class ID info to the head of the list */
class->flink = g_classregistry;
g_classregistry = class;
irqrestore(flags);
return OK;
}
+80
View File
@@ -0,0 +1,80 @@
/****************************************************************************
* drivers/usbhost/usbhost_registry.c
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/usb/usbhost.h>
#include "usbhost_registry.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/* g_classregistry is a singly-linkedlist of class ID information added by
* calls to usbhost_registerclass(). Since this list is accessed from USB
* host controller interrupt handling logic, accesses to this list must be
* protected by disabling interrupts.
*/
struct usbhost_registry_s *g_classregistry;
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
+87
View File
@@ -0,0 +1,87 @@
/****************************************************************************
* drivers/usbhost/usbdev_registry.h
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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.
*
****************************************************************************/
#ifndef __DRIVERS_USBHOST_USBHOST_REGISTRY_H
#define __DRIVERS_USBHOST_USBHOST_REGISTRY_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/usb/usbhost.h>
/****************************************************************************
* Definitions
****************************************************************************/
/* Configuration ************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
# define EXTERN extern "C"
extern "C"
{
#else
# define EXTERN extern
#endif
/* g_classregistry is a singly-linkedlist of class ID information added by
* calls to usbhost_registerclass(). Since this list is accessed from USB
* host controller interrupt handling logic, accesses to this list must be
* protected by disabling interrupts.
*/
EXTERN struct usbhost_registry_s *g_classregistry;
/************************************************************************************
* Public Function Prototypes
************************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* #define __DRIVERS_USBHOST_USBHOST_REGISTRY_H */
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff