Skip to content

Commit

Permalink
Fix/270 (#305)
Browse files Browse the repository at this point in the history
* Update code includes in AN00129 doc
  • Loading branch information
xross authored Dec 20, 2021
1 parent 49a7eac commit 74e44c7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 27 deletions.
33 changes: 12 additions & 21 deletions examples/AN00129_hid_class/doc/rst/AN00129.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,29 +107,20 @@ Looking at this in a more detail you can see the following:
Configuring the USB Device ID
.............................

The USB ID values used for vendor id, product id and device version number are defined in the file ``endpoint0.xc``. These are used by the host machine to determine the vendor of the device (in this case XMOS) and the product plus the firmware version.
The USB ID values used for vendor ID, product ID and device version number are defined in the file ``endpoint0.xc``. These are used by the host machine to determine the vendor of the device (in this case XMOS) and the product plus the firmware version.

.. literalinclude:: endpoint0.xc
:start-on: USB HID Device
:end-before: Standard

USB HID Class specific defines
..............................

The USB HID Class is configured in the file ``endpoint0.xc``. Below there are a set of standard defines which are used to configure the USB device descriptors to setup a USB HID class device running on an xCORE-USB microcontroller.

.. literalinclude:: endpoint0.xc
:start-on: Standard HID
:end-before: Device Descriptor
.. literalinclude:: hid_defs.h
:start-on: /* USB HID Device Product Defines
:end-before: /* Device Descriptor

|newpage|

USB Device Descriptor
.....................

``endpoint0.xc`` is where the standard USB device descriptor is declared for the HID class device. Below is the structure which contains this descriptor. This will be requested by the host when the device is enumerated on the USB bus.
``hid_defs.h`` is where the standard USB device descriptor is declared for the HID class device. Below is the structure which contains this descriptor. This will be requested by the host when the device is enumerated on the USB bus.

.. literalinclude:: endpoint0.xc
.. literalinclude:: hid_defs.h
:start-on: devDesc
:end-on: }

Expand All @@ -142,7 +133,7 @@ USB Configuration Descriptor

The USB configuration descriptor is used to configure the device in terms of the device class and the endpoint setup. For the USB HID class device the configuration descriptor which is read by the host is as follows.

.. literalinclude:: endpoint0.xc
.. literalinclude:: hid_defs.h
:start-on: cfgDesc
:end-on: }

Expand All @@ -155,7 +146,7 @@ USB HID Class Descriptor

For USB HID class devices there is a descriptor that is device in the HID device class specification which needs to be provided to the host in addition to the default decriptor types described above. The host will request this descriptor from the device when it enumerates as a HID class device. The HID descriptor for our mouse demo application is as follows.

.. literalinclude:: endpoint0.xc
.. literalinclude:: hid_defs.h
:start-on: hidDescriptor
:end-on: }

Expand All @@ -166,7 +157,7 @@ USB HID Report Descriptor

Along with the HID class descriptor there is a HID report descriptor which describes to the host the usage of the device and the data it will be reporting when it communicates. As HID devices are supported by standard drivers on a host machine this allow a level of configuration between the host and the device. The HID report descriptor for our example application is below.

.. literalinclude:: endpoint0.xc
.. literalinclude:: hid_defs.h
:start-on: hidReportDesc
:end-on: }

Expand All @@ -179,7 +170,7 @@ There are two further descriptors within this file relating to the
configuration of the USB Printer Class. These sections should also be
modified to match the capabilities of the printer.

.. literalinclude:: endpoint0.xc
.. literalinclude:: hid_defs.h
:start-on: String table
:end-on: }

Expand All @@ -191,7 +182,7 @@ USB HID Class requests
Inside ``endpoint0.xc`` there is a function for handling the USB HID device class specific requests. The code for handling these requests is shown as follows:

.. literalinclude:: endpoint0.xc
:lines: 142-198
:lines: 16-74

These HID specific requests are implemented by the application as they do not form part of the standard requests which have to be accepted by all device classes via endpoint0.

Expand All @@ -203,7 +194,7 @@ USB HID Class Endpoint0
The function ``Endpoint0()`` contains the code for dealing with device requests made from the host to the standard endpoint0 which is present in all USB devices. In addition to requests required for all devices, the code handles the requests specific to the HID class.

.. literalinclude:: endpoint0.xc
:lines: 201-301
:lines: 75-176

|newpage|

Expand Down
7 changes: 2 additions & 5 deletions examples/AN00129_hid_class/src/hid_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#define HID_REPORT_BUFFER_SIZE 3
extern unsigned char g_reportBuffer[HID_REPORT_BUFFER_SIZE];

#endif // HID_DEFS_H

/* USB HID Device Product Defines */
#define BCD_DEVICE 0x1000
#define VENDOR_ID 0x20B1
Expand Down Expand Up @@ -127,14 +125,13 @@ static unsigned char hidReportDescriptor[] =
0xC0 /* End Collection */
};

//unsafe{
/* String table */
//static char * unsafe stringDescriptors[]=
static char * stringDescriptors[]=
{
"\x09\x04", // Language ID string (US English)
"XMOS", // iManufacturer
"Example HID Mouse", // iProduct
"Config", // iConfiguration
};
//}

#endif // HID_DEFS_H
2 changes: 1 addition & 1 deletion lib_xud/doc/rst/version.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.. version:: 2.0.0
.. version:: 2.1.0

0 comments on commit 74e44c7

Please sign in to comment.