Skip to content

Commit

Permalink
Merge pull request #306 from xross/master
Browse files Browse the repository at this point in the history
Release 2.1.0
  • Loading branch information
xross authored Dec 20, 2021
2 parents f8592f2 + 174e67c commit be73b5b
Show file tree
Hide file tree
Showing 89 changed files with 2,958 additions and 1,461 deletions.
17 changes: 12 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ _build/
*.pyc
*.expect
*.so
*/logs/*
**/bin/**
**/tests/result/*
**/logs*/**
test_results.csv
.DS_Store
_README/**
Expand All @@ -30,9 +32,14 @@ Installs/
tests/bin.txt
tests/log
tests/test_**/**test_xs2.xn
tests/test_**/**test_xs3_500.xn
tests/test_**/**test_xs3_540.xn
tests/test_**/**test_xs3_600.xn
tests/test_**/**test_xs3_800.xn
tests/test_**/**test_xs3_*.xn
**/venv/**
*.gtkw
**/tests/build/**
**/tests/doc/**
**/build/html/**
**/tests/assets/**
**/build/docstrees/**
tests/report.html
tests/testplan.rst
build/doctrees/environment.pickle
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
lib_xud Change Log
==================

2.1.0
-----

* CHANGE: Various optimisations to aid corner-case timings on XS3 based
devices
* CHANGE: Some API functions re-authored in C (from Assembly)
* CHANGE: Testbench now more accurately models XS3 based devices

2.0.2
-----

Expand Down
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ The library provides functionality to act as a USB *device* only.

This library is for use with xCORE-200 Series or xCORE-AI series devices only, previous generations of xCORE devices are no longer supported.

Note, at points lib_xud will run in "fast mode" this is a requirement to meet timing.

Features
........

Expand Down
8 changes: 7 additions & 1 deletion examples/AN00129_hid_class/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ BUILD_FLAGS = -O3 -report -fxscope

XCC_FLAGS_200 = $(BUILD_FLAGS)
XCC_FLAGS_AI = $(BUILD_FLAGS)
XCC_FLAGS_AI_C = $(BUILD_FLAGS)

USED_MODULES = lib_xud

Expand All @@ -28,10 +29,15 @@ USED_MODULES = lib_xud
# In this case, the target depends on the build configuration.
ifeq ($(CONFIG),AI)
TARGET = XCORE-AI-EXPLORER
EXCLUDE_FILES = main.c
else ifeq ($(CONFIG),AI_C)
TARGET = XCORE-AI-EXPLORER
EXCLUDE_FILES = main.xc \
endpoint0.xc
else
TARGET = XCORE-200-EXPLORER
EXCLUDE_FILES = main.c
endif

#=============================================================================
# The following part of the Makefile includes the common build infrastructure
# for compiling XMOS applications. You should not need to edit below here.
Expand Down
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
125 changes: 0 additions & 125 deletions examples/AN00129_hid_class/src/endpoint0.xc
Original file line number Diff line number Diff line change
Expand Up @@ -8,131 +8,6 @@
#include "hid.h"
#include "hid_defs.h"

/* USB HID Device Product Defines */
#define BCD_DEVICE 0x1000
#define VENDOR_ID 0x20B1
#define PRODUCT_ID 0x1010

/* Device Descriptor */
static unsigned char devDesc[] =
{
0x12, /* 0 bLength */
USB_DESCTYPE_DEVICE, /* 1 bdescriptorType */
0x00, /* 2 bcdUSB */
0x02, /* 3 bcdUSB */
0x00, /* 4 bDeviceClass */
0x00, /* 5 bDeviceSubClass */
0x00, /* 6 bDeviceProtocol */
0x40, /* 7 bMaxPacketSize */
(VENDOR_ID & 0xFF), /* 8 idVendor */
(VENDOR_ID >> 8), /* 9 idVendor */
(PRODUCT_ID & 0xFF), /* 10 idProduct */
(PRODUCT_ID >> 8), /* 11 idProduct */
(BCD_DEVICE & 0xFF), /* 12 bcdDevice */
(BCD_DEVICE >> 8), /* 13 bcdDevice */
0x01, /* 14 iManufacturer */
0x02, /* 15 iProduct */
0x00, /* 16 iSerialNumber */
0x01 /* 17 bNumConfigurations */
};


/* Configuration Descriptor */
static unsigned char cfgDesc[] = {
0x09, /* 0 bLength */
0x02, /* 1 bDescriptortype */
0x22, 0x00, /* 2 wTotalLength */
0x01, /* 4 bNumInterfaces */
0x01, /* 5 bConfigurationValue */
0x03, /* 6 iConfiguration */
0x80, /* 7 bmAttributes */
0xC8, /* 8 bMaxPower */

0x09, /* 0 bLength */
0x04, /* 1 bDescriptorType */
0x00, /* 2 bInterfacecNumber */
0x00, /* 3 bAlternateSetting */
0x01, /* 4: bNumEndpoints */
0x03, /* 5: bInterfaceClass */
0x00, /* 6: bInterfaceSubClass */
0x02, /* 7: bInterfaceProtocol*/
0x00, /* 8 iInterface */

0x09, /* 0 bLength. Note this is currently
replicated in hidDescriptor[] below */
0x21, /* 1 bDescriptorType (HID) */
0x11, /* 2 bcdHID */
0x01, /* 3 bcdHID */
0x00, /* 4 bCountryCode */
0x01, /* 5 bNumDescriptors */
0x22, /* 6 bDescriptorType[0] (Report) */
0x32, /* 7 wDescriptorLength */
0x00, /* 8 wDescriptorLength */

0x07, /* 0 bLength */
0x05, /* 1 bDescriptorType */
0x81, /* 2 bEndpointAddress */
0x03, /* 3 bmAttributes */
0x40, /* 4 wMaxPacketSize */
0x00, /* 5 wMaxPacketSize */
0x0a /* 6 bInterval */
};

static unsigned char hidDescriptor[] =
{
0x09, /* 0 bLength */
0x21, /* 1 bDescriptorType (HID) */
0x11, /* 2 bcdHID */
0x01, /* 3 bcdHID */
0x00, /* 4 bCountryCode */
0x01, /* 5 bNumDescriptors */
0x22, /* 6 bDescriptorType[0] (Report) */
0x32, /* 7 wDescriptorLength */
0x00, /* 8 wDescriptorLength */
};

/* HID Report Descriptor */
static unsigned char hidReportDescriptor[] =
{
0x05, 0x01, /* Usage Page (Generic Desktop) */
0x09, 0x02, /* Usage (Mouse) */
0xA1, 0x01, /* Collection (Application) */
0x09, 0x01, /* Usage (Pointer) */
0xA1, 0x00, /* Collection (Physical) */
0x05, 0x09, /* Usage Page (Buttons) */
0x19, 0x01, /* Usage Minimum (01) */
0x29, 0x03, /* Usage Maximum (03) */
0x15, 0x00, /* Logical Minimum (0) */
0x25, 0x01, /* Logical Maximum (1) */
0x95, 0x03, /* Report Count (3) */
0x75, 0x01, /* Report Size (1) */
0x81, 0x02, /* Input (Data,Variable,Absolute); 3 button bits */
0x95, 0x01, /* Report Count (1) */
0x75, 0x05, /* Report Size (5) */
0x81, 0x01, /* Input(Constant); 5 bit padding */
0x05, 0x01, /* Usage Page (Generic Desktop) */
0x09, 0x30, /* Usage (X) */
0x09, 0x31, /* Usage (Y) */
0x15, 0x81, /* Logical Minimum (-127) */
0x25, 0x7F, /* Logical Maximum (127) */
0x75, 0x08, /* Report Size (8) */
0x95, 0x02, /* Report Count (2) */
0x81, 0x06, /* Input (Data,Variable,Relative); 2 position bytes (X & Y) */
0xC0, /* End Collection */
0xC0 /* End Collection */
};

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

/* It is essential that HID_REPORT_BUFFER_SIZE, defined in hid_defs.h, matches the */
/* infered length of the report described in hidReportDescriptor above. In this case */
/* it is three bytes, three button bits padded to a byte, plus a byte each for X & Y */
Expand Down
Loading

0 comments on commit be73b5b

Please sign in to comment.