mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
Fleshing out keyboard driver
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3250 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -72,7 +72,7 @@
|
||||
#define DEV_FORMAT "/dev/sd%c"
|
||||
#define DEV_NAMELEN 10
|
||||
|
||||
/* Used in usbhost_connect() */
|
||||
/* Used in usbhost_cfgdesc() */
|
||||
|
||||
#define USBHOST_IFFOUND 0x01
|
||||
#define USBHOST_BINFOUND 0x02
|
||||
@@ -135,6 +135,9 @@ static inline void usbhost_mkdevname(FAR struct usbhost_state_s *priv, char *dev
|
||||
/* Worker thread actions */
|
||||
|
||||
static void usbhost_destroy(FAR void *arg);
|
||||
|
||||
/* Helpers for usbhost_connect() */
|
||||
|
||||
static inline int usbhost_cfgdesc(FAR struct usbhost_state_s *priv,
|
||||
FAR const uint8_t *configdesc, int desclen,
|
||||
uint8_t funcaddr);
|
||||
@@ -453,7 +456,9 @@ static inline int usbhost_cfgdesc(FAR struct usbhost_state_s *priv,
|
||||
DEBUGASSERT(remaining >= USB_SIZEOF_IFDESC);
|
||||
if ((found & USBHOST_IFFOUND) != 0)
|
||||
{
|
||||
/* Oops.. more than one interface. We don't know what to do with this. */
|
||||
/* Oops.. more than one interface. We don't know what to
|
||||
* do with this.
|
||||
*/
|
||||
|
||||
return -ENOSYS;
|
||||
}
|
||||
@@ -461,15 +466,16 @@ static inline int usbhost_cfgdesc(FAR struct usbhost_state_s *priv,
|
||||
}
|
||||
break;
|
||||
|
||||
/* Endpoint descriptor. We expect two bulk endpoints, an IN and an OUT */
|
||||
/* Endpoint descriptor. Here, we expect two bulk endpoints, an IN
|
||||
* and an OUT.
|
||||
*/
|
||||
|
||||
case USB_DESC_TYPE_ENDPOINT:
|
||||
{
|
||||
FAR struct usb_epdesc_s *epdesc = (FAR struct usb_epdesc_s *)configdesc;
|
||||
DEBUGASSERT(remaining >= USB_SIZEOF_EPDESC);
|
||||
|
||||
/* Check for a bulk endpoint. We only support the bulk-only
|
||||
* protocol so I suppose anything else should really be an error.
|
||||
*/
|
||||
/* Check for a bulk endpoint. */
|
||||
|
||||
if ((epdesc->attr & USB_EP_ATTR_XFERTYPE_MASK) == USB_EP_ATTR_XFER_BULK)
|
||||
{
|
||||
@@ -477,11 +483,15 @@ static inline int usbhost_cfgdesc(FAR struct usbhost_state_s *priv,
|
||||
|
||||
if (USB_ISEPOUT(epdesc->addr))
|
||||
{
|
||||
/* It is an OUT bulk endpoint. There should be only one bulk OUT endpoint. */
|
||||
/* It is an OUT bulk endpoint. There should be only one
|
||||
* bulk OUT endpoint.
|
||||
*/
|
||||
|
||||
if ((found & USBHOST_BOUTFOUND) != 0)
|
||||
{
|
||||
/* Oops.. more than one interface. We don't know what to do with this. */
|
||||
/* Oops.. more than one endpoint. We don't know
|
||||
* what to do with this.
|
||||
*/
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -498,11 +508,15 @@ static inline int usbhost_cfgdesc(FAR struct usbhost_state_s *priv,
|
||||
}
|
||||
else
|
||||
{
|
||||
/* It is an IN bulk endpoint. There should be only one bulk IN endpoint. */
|
||||
/* It is an IN bulk endpoint. There should be only one
|
||||
* bulk IN endpoint.
|
||||
*/
|
||||
|
||||
if ((found & USBHOST_BINFOUND) != 0)
|
||||
{
|
||||
/* Oops.. more than one interface. We don't know what to do with this. */
|
||||
/* Oops.. more than one endpoint. We don't know
|
||||
* what to do with this.
|
||||
*/
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -1014,9 +1028,9 @@ static int usbhost_disconnected(struct usbhost_class_s *class)
|
||||
* Name: usbhost_skelinit
|
||||
*
|
||||
* Description:
|
||||
* Initialize the USB storage class. This function should be called
|
||||
* Initialize the USB class driver. This function should be called
|
||||
* be platform-specific code in order to initialize and register support
|
||||
* for the USB host storage class.
|
||||
* for the USB host class device.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
|
||||
@@ -186,6 +186,9 @@ static inline int usbhost_inquiry(FAR struct usbhost_state_s *priv);
|
||||
/* Worker thread actions */
|
||||
|
||||
static void usbhost_destroy(FAR void *arg);
|
||||
|
||||
/* Helpers for usbhost_connect() */
|
||||
|
||||
static inline int usbhost_cfgdesc(FAR struct usbhost_state_s *priv,
|
||||
FAR const uint8_t *configdesc, int desclen,
|
||||
uint8_t funcaddr);
|
||||
@@ -987,7 +990,9 @@ static inline int usbhost_cfgdesc(FAR struct usbhost_state_s *priv,
|
||||
DEBUGASSERT(remaining >= USB_SIZEOF_IFDESC);
|
||||
if ((found & USBHOST_IFFOUND) != 0)
|
||||
{
|
||||
/* Oops.. more than one interface. We don't know what to do with this. */
|
||||
/* Oops.. more than one interface. We don't know what to
|
||||
* do with this.
|
||||
*/
|
||||
|
||||
return -ENOSYS;
|
||||
}
|
||||
@@ -995,7 +1000,10 @@ static inline int usbhost_cfgdesc(FAR struct usbhost_state_s *priv,
|
||||
}
|
||||
break;
|
||||
|
||||
/* Endpoint descriptor. We expect two bulk endpoints, an IN and an OUT */
|
||||
/* Endpoint descriptor. We expect two bulk endpoints, an IN and an
|
||||
* OUT.
|
||||
*/
|
||||
|
||||
case USB_DESC_TYPE_ENDPOINT:
|
||||
{
|
||||
FAR struct usb_epdesc_s *epdesc = (FAR struct usb_epdesc_s *)configdesc;
|
||||
@@ -1011,11 +1019,15 @@ static inline int usbhost_cfgdesc(FAR struct usbhost_state_s *priv,
|
||||
|
||||
if (USB_ISEPOUT(epdesc->addr))
|
||||
{
|
||||
/* It is an OUT bulk endpoint. There should be only one bulk OUT endpoint. */
|
||||
/* It is an OUT bulk endpoint. There should be only one
|
||||
* bulk OUT endpoint.
|
||||
*/
|
||||
|
||||
if ((found & USBHOST_BOUTFOUND) != 0)
|
||||
{
|
||||
/* Oops.. more than one interface. We don't know what to do with this. */
|
||||
/* Oops.. more than one endpoint. We don't know
|
||||
* what to do with this.
|
||||
*/
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -1032,11 +1044,15 @@ static inline int usbhost_cfgdesc(FAR struct usbhost_state_s *priv,
|
||||
}
|
||||
else
|
||||
{
|
||||
/* It is an IN bulk endpoint. There should be only one bulk IN endpoint. */
|
||||
/* It is an IN bulk endpoint. There should be only one
|
||||
* bulk IN endpoint.
|
||||
*/
|
||||
|
||||
if ((found & USBHOST_BINFOUND) != 0)
|
||||
{
|
||||
/* Oops.. more than one interface. We don't know what to do with this. */
|
||||
/* Oops.. more than one endpoint. We don't know
|
||||
* what to do with this.
|
||||
*/
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -488,7 +488,22 @@
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
/* HID Descriptor (HID 6.2.1) ***********************************************/
|
||||
|
||||
struct usbhid_descriptor_s
|
||||
{
|
||||
uint8_t len; /* Size of the HID descriptor */
|
||||
uint8_t type; /* HID descriptor type */
|
||||
uint8_t hid[2]; /* HID class specification release */
|
||||
uint8_t country; /* Country code */
|
||||
uint8_t ndesc; /* Number of descriptors (>=1) */
|
||||
uint8_t classdesc; /* Class descriptor type (See 7.1) */
|
||||
uint8_t desclen[2]; /* Size of the report descriptor */
|
||||
uint8_t optdesc; /* Type of optional descriptor */
|
||||
uint8_t optlen[2]; /* Size of the optional descriptor */
|
||||
};
|
||||
|
||||
/* Standard Reports *********************************************************/
|
||||
/* Keyboard input report (8 bytes) (HID B.1) */
|
||||
|
||||
struct usbhid_kbdreport_s
|
||||
|
||||
Reference in New Issue
Block a user