Commit graph

92 commits

Author SHA1 Message Date
Johann Fischer cf14a60f5a include: usb: add descriptor and data section macros
This patch adds USB descriptor and data section macros.

Use USBD_DESCR_..._DEFINE macros to place the parts of USB device
descriptor in predetermined order in the USB descriptor
section. The parts of a device descriptor are also
sorted according to the macro argument. All parts of a
particular device descriptor must use the same argument.

Use USBD_CFG_DATA_DEFINE macro to place the data struct
of a class driver or function in the USB data section.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-06-15 11:02:05 +02:00
Johann Fischer 46700eaa65 include: usb: add USB DFU class header
Add USB DFU class header.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-04-30 17:42:40 -04:00
Andrei Emeltchenko 4f84cf782d usb: Add BOS Descriptors
Add Binary Device Object Store descriptors

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-04-20 21:04:42 -07:00
Michael Hope 5f67a6119d include: improve compatibility with C++ apps.
This patch lets a C++ application use more of Zephyr by adding guards
and changeing some constructs to the C++11 equivalent.

Changes include:

- Adding guards
- Switching to static_assert
- Switching to a template for ARRAY_SIZE as g++ doesn't have the
  builtin.
- Re-ordering designated initialisers to match the struct field order
  as G++ only supports simple designated initialisers.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-04-09 23:21:52 -04:00
Michael Hope 0d04aef6fe usb: hid: add a INT IN transfer complete callback.
int_in_ready is an optional callback that is called when the current
interrupt IN transfer has completed.  This can be used to wait for the
endpoint to go idle or to trigger the next transfer.

This is needed for protocols like FIDO U2F that use the interrupt
endpoint for transfers.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-04-06 23:06:07 -04:00
Andrei Emeltchenko efa3a137cf usb: Remove duplicated ACM_SUBCLASS definition
ACM_SUBCLASS is already defined in USB CDC header.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-04-04 08:21:06 -04:00
Andrei Emeltchenko 4291fb67a3 usb: Remove duplicated CDC_ECM_SUBCLASS definition
Use ECM_SUBCLASS instead.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-04-04 08:21:06 -04:00
qianfan Zhao 3cac6b249c usb: hid: Add macros for REPORT descriptor
Add macros for constructing HID Report Descriptors

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
2018-03-28 10:44:58 -04:00
Michael Hope 4d6d04d3ea hid: change the API table to const.
A minor change to put the API function table into flash.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-03-21 19:45:11 -04:00
Loic Poulain 16921b0698 usb: Add transfer management API
The transfer API provides 'high' level functions to manage sending and
reception of USB data. A USB (class) driver has to register the generic
usb_transfer_ep_callback as endpoint status callback in order to use
the API.

With this API, the class driver does not need to take care of low-level
usb transfer management (packet splitting, ZLP, synchronization...).
The usb_transfer methods will split transfer into multiple transactions
depending endpoint max size and controller capabilities.

Once the transfer is completed, class driver is notified by a callback.
The usb_transfer method can be executed in IRQ/atomic context.
A usb_transfer synchronous helper exists which block-waits until
transfer completion.

In write case, a transfer is complete when all data has been sent.
In read case, a transfer is complete when the exact amount of data
requested has been received or if a short-pkt (including ZLP) is
received.

transfer methods are thread-safe.

A transfer can be cancelled at any time.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2018-03-16 14:45:24 -07:00
Iván Sánchez Ortega fa57ebd5b7 usb: Rename unicode into UTF16LE
In order to avoid confusion between "Unicode", UTF8, UTF16, UTF32,
and endianess of these encodings, rename all instances of "Unicode"
in the USB subsystem and samples into "UTF16LE".

Signed-off-by: Iván Sánchez Ortega <ivan@sanchezortega.es>
2018-03-14 13:40:59 +01:00
Andrei Emeltchenko 34af27d6ac usb: hid: Remove duplicated definitions
Remove duplicated definitions defined elsewhere.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-02-05 06:39:50 -08:00
Andrei Emeltchenko 303c4cd6ae usb: cdc: Remove duplicated class code
Class COMMUNICATION_DEVICE_CLASS is specified in common header
already.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-02-05 06:39:50 -08:00
Andrei Emeltchenko 9ed9315cd4 usb: msc: Remove duplicated class code
Keep MASS_STORAGE_CLASS defined only once

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-02-05 06:39:50 -08:00
Andrei Emeltchenko f908387e9a usb: hid: Add macros for REPORT descriptor
Add macros for constructing HID Report Descriptors.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-31 07:42:19 -05:00
Andrei Emeltchenko ad12038442 usb: hid: Use typedef for callbacks
Change to typedefs.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-31 07:42:19 -05:00
Andrei Emeltchenko e8ccb16986 usb: hid: Add Human Interface Device (HID) class
Add support for Human Interface Device USB class.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-31 07:42:19 -05:00
Andrei Emeltchenko 2a28194364 usb: Add missing definitions needed for RNDIS
Add missing CDC definitions for RNDIS.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Patrik Flykt 010fb40b95 subsys: usb: Set Zephyr project USB Vendor and Product IDs
Document USB Vendor and Product IDs and their intended usage.
Set the Vendor and Product IDs and define the USB bcdDevice
Device Descriptor Device Release Number to be the binary
coded decimal representation of the Zephyr major and minor
kernel version number.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-01-15 15:47:53 -05:00
Johann Fischer e9f3791d78 include: usb: remove cdc_acm.h
This header is replaced by usb_cdc.h and is no longer needed.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2017-11-07 15:31:02 -05:00
David B. Kinder 4600c37ff1 doc: Fix misspellings in header/doxygen comments
Occasional scan for misspellings missed during PR reviews

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-10-17 19:40:29 -04:00
Loic Poulain f74190f829 usb: Add USB definitions for EEM device
Add CDC Ethernet Emulation Model subclass and protocol codes.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2017-10-16 14:47:47 -04:00
Johann Fischer d00685857a include: usb: remove mass_storage header
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2017-10-13 08:32:37 -04:00
Johann Fischer eb501f6253 include: usb: fix style and add standard descriptors to usb_common.h
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2017-10-13 07:47:48 -04:00
Johann Fischer d579e577eb include: usb: add usb_msc.h header for MSC devices
Add Mass Storage Class header. The header is based on mass_storage.h,
has been cleaned up and extended by the Class and Protocol Codes.
mass_storage.h will be removed after mass_storage.c has been reworked.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2017-10-13 07:47:48 -04:00
Johann Fischer 39f0592f54 include: usb: add usb_cdc.h header for CDC ACM/ECM devices
Add USB Communicatons Device Class header. Currently
limited to ACM and ECM devices.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2017-10-13 07:47:48 -04:00
Anas Nashif 71a927955e usb: move headers to include/usb/class
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-03 14:50:14 -04:00
Andrei Emeltchenko 54831ec5c7 usb: webusb: Move USB version definition to right place
Make it possible to reuse definitions from other samples.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-09-21 13:10:04 -04:00
Andrei Emeltchenko 4efaefba5c usb: Allow to select configuration for composite devices
Composite multifunction USB devices should be able to know about
configuration change, implement it through existing callback.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-09-21 09:00:23 -04:00
Andrei Emeltchenko 0aebb0faf4 usb: Add USB definitions for RNDIS Ethernet device
And useful definitions for composite device with RNDIS Ethernet
function.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-09-21 09:00:23 -04:00
Andrei Emeltchenko b60a0af586 usb: Add DEVICE_QUAL descriptor definitions
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-09-21 09:00:23 -04:00
Andrei Emeltchenko 03d6692d30 usb: Add Custom subclass definition
Change-Id: I2a3d15ce45f3a44c5fbb5986c91bcc66621796b0
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-09-21 09:00:23 -04:00
Andrei Emeltchenko e2b90cdf68 usb: Update USB common definitions
Add support for USB 2.0 and NCM CDC protocol

Change-Id: Ib815b7d9d02d404b5dfbcc8aba1fcd7e6de71bd3
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-09-21 09:00:23 -04:00
Andrei Emeltchenko edea77b155 usb: Add Ethernet Control Mode (ECM) subclass definition
Change-Id: Ie7dd270de9d972ac8e09255a930fe42295ae1533
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-09-21 09:00:23 -04:00
David B. Kinder fc5f2b3832 doc: spelling check doxygen comments include/
fix misspellings found in doxygen comments used for API docs

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-05-02 22:21:37 -04:00
Kumar Gala cc334c7273 Convert remaining code to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.  This handles the remaining includes and kernel, plus
touching up various points that we skipped because of include
dependancies.  We also convert the PRI printf formatters in the arch
code over to normal formatters.

Jira: ZEP-2051

Change-Id: Iecbb12601a3ee4ea936fd7ddea37788a645b08b0
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 11:38:23 -05:00
Kumar Gala 99937a77da usb: Change transfer_len type to int32_t in usb_request_handler typedef
The functions that implement usb_request_handlers are already using an
int32_t for transfer_len, so lets make the typedef match.  This address
a potential issue in the future when the typedef of int32_t changes (or
when building with newlib).

Change-Id: I6e478551c38f2040b0dcec47c2e4c565c27acdd0
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-30 12:01:49 +00:00
Jithu Joseph 7eab305593 usb: Add end-point stall APIs and flow control APIS
USB class drivers may need to offload some work from
upcall interrupt context to a background fiber. This
requires some way to defer taking more data from host
till the offloaded work completes. Two APIs are added to
achieve this.

Further USB class drivers sometimes need to set STALL condition
on end-points to signal errors to host.These too are
added.

Change-Id: Ic973522c3394e23d7f9c4c67affc0cd050afc20f
Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
2016-11-09 02:45:46 +00:00
Anas Nashif 4d090e09d6 usb: move usb subsystem to subsys/usb and cleanup header inclusion
Change-Id: I5bdfd2cf5fee62af2ca772d778477f4f378a6a55
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-10-31 19:21:42 +00:00
Andrei Emeltchenko 4cccc24391 usb: Add Bluetooth class codes definitions
Change-Id: Idc60324bcf9ee3e9a3ce9a24b71cf5ae5b339792
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-08-10 15:27:35 +00:00
Adrian Bradianu ab2c18b0ad usb: Move LOW_BYTE and HIGH_BYTE to samples code
Move LOW_BYTE and HIGH_BYTE macros from usb_common.h to
samples code.

Change-Id: I26296bde8c5b3991b3bfab71272c861b5360ce97
Signed-off-by: Adrian Bradianu <adrian.bradianu@windriver.com>
Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
2016-06-30 17:51:58 +00:00
Adrian Bradianu 7a16ade6d1 usb: Add USB device core layer
USB Device core layer is a hardware independent interface between USB
device controller driver and USB device class drivers or customer
applications. It's a port of the LPCUSB device stack.

Change-Id: I9371ffab7034d20953fec0525e72fbe9e094c931
Signed-off-by: Adrian Bradianu <adrian.bradianu@windriver.com>
Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
2016-06-30 17:51:56 +00:00