Commit graph

92 commits

Author SHA1 Message Date
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Emil Obalski 8d2f13c203 usb: Add USB audio implementation
By this commit USB audio class implementation is introduced
to Zephyr.

The Zephyr USB audio device class follows bellow
documentations:

- Universal Serial Bus specification rev2.0 (usb20.pdf)
- Universal Serial Bus Device Class Definition for Audio Devices
  (audio10.pdf)
- Universal Serial Bus Device Class Definition for Audio Data Formats
  (frmts10.pdf)
- Universal Serial Bus Device Class Definition for Terminal Types
  (termt10.pdf)

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-05-08 15:12:27 +02:00
Emil Obalski 98c9cebfac usb: Add Audio class related files
This commit adds files related to USB audio device class.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-05-08 15:12:27 +02:00
Emil Obalski 45bdb23005 usb: Special return values for custom_handler
This commit introduces dedicated return type for custom_handler.
Relevant code is updated to fulfill the API documentation.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-05-07 11:20:27 +02:00
Emil Obalski 8fa51bca58 usb: Allow Audio Class to handle custom_hander for all interfaces
This exception allows USB Audio Class to properly respond to the
interface requests.

This commit is temporary solution and shall not be considered as
valid solution for other classes.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-05-07 11:20:27 +02:00
Barry Solomon 6118ca2785 usb: make usb descriptor power options configurable
Add two new kconfig options USB_SELF_POWERED and USB_MAX_POWER.
These can be set by the user to change the USB configuration descriptor.
USB_MAX_POWER can be set to any value between 0 and 250, but practically
should be 50 or 250. These values are half the ammount of mA that the
device will tell the host that it needs.
USB_SELF_POWERED sets the 7th bit in bmAttributes of the USB config
descriptor. Should be set to y if the device has its own power source
other than USB.

Signed-off-by: Barry Solomon <barry.solomon@dexcom.com>
2019-12-20 19:46:16 -05:00
Emil Obalski 2128750138 usb: api: Add user device status callback
By this commit user gets possibility to register USB
device satutus callback. This callback represents device state
and is added so user could know what happend to USB device.

Callback is registered by providing it to usb_enable()
USB api is extended by this callback handler.

Samples using using USB are by default provide no callback
and the usb_enable() is called with NULL parameter.

Status callback registered by hid class is deleted as now
USB device has global callback for all classes within device.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2019-12-19 13:08:55 +01:00
Emil Obalski d65027d8c0 usb: samples: Application calling usb_enable by itself
User app is reponsible for issuing usb_enable and
making USB hardware operative.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2019-12-19 13:08:55 +01:00
Emil Obalski 85a08da966 usb: Rename defines to match present naming convention
This commit renames two defines:
CS_INTERFACE -> USB_CS_INTERFACE_DESC
CS_ENDPOINT -> USB_CS_ENDPOINT_DESC
in order to match current naming convention when it comes
to descriptors fields.

All relevant files are updated to match renamed macros.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2019-12-09 12:48:13 -05:00
Emil Obalski c1f5e11bb6 usb: Cleanup for multiplied defines
Some of defines are present in several header files.
Those defines are the same with value but with different naming.

Common defines are brought to usb_common.h

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2019-12-09 12:48:13 -05:00
Arnaud Taffanel a06a6da03b usb: Fix BCD() macro used to set bcdDevice
According to API documentation, the bcdDevice field of the USB
descriptor is supposed to represents the Zephyr kernel major
and minor versions as a binary coded decimal value. However,
when using zephyr 2.0, bcdDevice is shown as 0.00 instead of 2.00.

This is due to a typo in the implementation of the BCD macro in
usb_commond.h. This commit fixes the macro.

Signed-off-by: Arnaud Taffanel <arnaud@bitcraze.io>
2019-11-20 19:38:13 +01:00
Peter A. Bigot a58d8ebaa6 driver: uart: make deprecation effective
Several macros were documented as deprecated but lacked the
infrastructure to produce deprecation warnings.  Add the deprecation
marker, and fix the in-tree references to the deprecated spellings.

Note that one non-deprecated macro should have been deprecated, and
is, referring to a newly added line control bit.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-11-07 12:44:15 -06:00
Johann Fischer abaeaed2af usb: sort usb config data by section
USBD_CFG_DATA_DEFINE macro has not consider that a class
could have more than one set of usb_cfg_data struct.
If a class has more than one set of usb_cfg_data
then they should be sorted the same way like by
USBD_DEVICE_DESCR_DEFINE macro.

Fixes: #16240

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-06-27 12:18:05 +02:00
Nicolas Pitre 9d11900dc3 usb: enforce byte alignment on USB records
As seen previously, some toolchain are willing to insert padding
at section changes to apply greater alignments by default. This is
especially true with 64-bit builds. USB structures are marked with the
packed attribute and therefore the linker section they land into
must also be byte aligned.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-06-17 16:41:43 -04:00
Andrei Emeltchenko 3880a42375 usb: Align legacy and composite interface
Remove duplicated execution path for composite configuration, USB
device stack initialization is done inside stack for both cases.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-27 09:25:06 -04:00
Aurelien Jarno 819e749ccd usb: move the request handler buffer to the USB device code
In order to unify the legacy and composite code, move the class and
vendor request handler buffer into the USB device code, just like in
composite mode. The option is renamed from USB_COMPOSITE_BUFFER_SIZE
into USB_REQUEST_BUFFER_SIZE and also replaces the USB_DFU_MAX_XFER_SIZE
and USB_HID_MAX_PAYLOAD_SIZE options.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-27 09:25:06 -04:00
Andrei Emeltchenko bf76b2acc3 usb: device: Add transfer cancel helper
Add usb_cancel_transfers() helper to cancel all ongoing transfers.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-22 11:19:49 +02:00
Andrei Emeltchenko 2c672b92c8 usb: device: Add usb_transfer_is_busy() function
Add usb_transfer_is_busy() function to check if there is ongoing
transfer.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-07 23:11:44 -04:00
Marcin Szymczyk ea7afdde8f usb: cdc_acm: SerialState notification full support
Added bBreak, bRingSignal, bFraming, bParity and bOverRun
handling in cdc_acm_line_ctrl_set.
Reference: Chapter 6.5.4 of Universal Serial Bus Communications Class
Subclass Specification for PSTN Devices rev 1.2

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2019-04-19 13:36:32 -05:00
Johann Fischer 65fd5859a4 include: usb: add FS MPS for different endpoint types
Add full speed maximum packet size for different endpoint types.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-04-11 13:35:24 -04:00
Johann Fischer c13e201b18 usb: replace MAX_PACKET_SIZE0 with meaningful USB_MAX_CTRL_MPS
Replace MAX_PACKET_SIZE0 with meaningful USB_MAX_CTRL_MPS.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-04-11 13:35:24 -04:00
Andrei Emeltchenko 721f3d1cd0 usb: Refactor USB status callback
Merge cb_usb_status_composite and cb_usb_status and use common
forward_status_cb for both composite and normal devices.

Fixes #14882

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-05 12:23:57 +02:00
Rajavardhan Gundi fa49e3e4c7 usb: dfu: Signal completion of DFU
Generally when DFU is in progress, the system is not expected to
be doing anything else in addition. Hence, a completion signal
would help the system to know that DFU is over and it can proceed
towards next tasks.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2019-03-08 08:35:59 -05:00
Marcin Szymczyk e13464bda2 usb: hid: add keyboard report macro and enums
Added macro that generates simple report descriptor for keyboard.
Added enums for standard button codes, keyboard modifiers
and keyboard LEDs.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2019-03-05 09:35:26 +01:00
Paweł Zadrożniak 3ecbff501a usb: Add remote wakeup support
This commit adds support for remote wakeup and extends USB api
with a wakeup request call. Remote wakeup can be dsabled in kconfig
when a specific driver does not support this feature.

Signed-off-by: Paweł Zadrożniak <pawel.zadrozniak@nordicsemi.no>
2019-02-27 10:37:16 +01:00
Andrei Emeltchenko ca85890dc2 usb: hid: Add HID Device concept
Add HID Device associated with the instance of the HID. This allows to
create several HID instances for multifunction composite device.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko b48a8c3247 usb: device: Add composite status callback
Add new status callback with usb_cfg_data parameter to be able to
identify instance callback.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko 9ef8ad412f usb: Refactor usb_interface_config callback
Add interface parameter to interface configuration callback to be able
to configure several instances of the same class.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko bf9c6d72e8 usb: Add instance parameter to descriptors definitions
This allows to place instances of the class one after another in the
linker section.

Fixes #12908

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-01 19:11:32 -05:00
Marcin Szymczyk c716f9c5aa usb: hid: macro for report descriptor
Added macro that generates simple report descriptor for mouse.
This improves the readability of hid-mouse sample.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2019-01-10 08:58:31 -05:00
Marcin Szymczyk 801b54edb9 usb: hid: boot protocol
Set_Protocol and Get_Protocol requests are handled now.
Tested with USB3CV.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2018-12-19 07:36:18 -06:00
Marcin Szymczyk d5b79ff42c usb: hid: implement idle rate
Idle rate functionality has been implemented for HID USB class.
Bassed on Device Class Definition for Human Interface Devices 1.11.
Tested with USB3CV and host with idle rate.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2018-12-04 15:58:19 -05:00
Andrei Emeltchenko 85cfe33262 usb: hid: Define helper definitions and cleanup code
Use newly defined definitions for cleaning the code.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-13 12:41:39 +01:00
Andrei Emeltchenko 93bd26343e usb: logs: Rename USB_WRN to LOG_WRN
Since logger is now suitable for our logs use it directly.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-08 08:35:20 -05:00
Andrei Emeltchenko f22060cdbe usb: logs: Rename USB_INF to LOG_INF
Since logger is now suitable for our logs use it directly.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-08 08:35:20 -05:00
Andrei Emeltchenko 17f7abd3dc usb: logs: Rename USB_ERR to LOG_ERR
Since logger is now suitable for our logs use it directly.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-08 08:35:20 -05:00
Andrei Emeltchenko 92c7ab74c0 usb: logs: Rename USB_DBG to LOG_DBG
Since logger is now suitable for our logs use it directly.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-08 08:35:20 -05:00
Andrei Emeltchenko c579414263 usb: Do not include function name twice
When CONFIG_LOG_FUNCTION_NAME is defined to not add name again.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-08 08:35:20 -05:00
Andrei Emeltchenko adf056dc92 usb: Use always single callback definition
Use one callback type, remove duplicates.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-10-10 09:21:55 -04:00
Andrei Emeltchenko 3288da9c0b usb: hid: Add status_cb to hid ops
Adding status callback allows to control report sending only when i.e.
device is connected or configured.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-10-10 09:21:55 -04:00
Yannis Damigos 452c3d6a87 include/usb/usb_device: Add USB_* log macros
Add USB_DBG, USB_WRN, USB_ERR, USB_INF macros
in usb_device header file and remove them
from usb device drivers.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-10-08 12:54:57 -04:00
David B. Kinder 1692790d32 doc: fix misspellings in API headers
Fix misspellings in header file doxygen comments used to generate API
documentation, missed during regular reviews.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-09-27 05:57:14 +05:30
Flavio Ceolin 4a211ec241 include: Add missing headers guard
Add missing headers guard

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-17 15:49:26 -04:00
Flavio Ceolin 67ca176754 headers: Fix headers across the project
Any word started with underscore followed by and uppercase letter or a
second underscore is a reserved word according with C99.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-17 15:49:26 -04:00
Andrei Emeltchenko ce6de827f3 usb: device: Clean doxygen documentation
Clean USB Device Layer documentation and create _usb_device_core_api
doxygen group.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-09-11 12:54:47 -04:00
Savinay Dharmappa 6b44a00336 subsys: usb: class: hid: Add OUT interrupt endpoint
patch add a OUT interrupt endpoint descriptor and registers a
corresponding notification callback with usb driver, which is invoked
when data is sent to device from host.

Implement the read ready notification as suggesteed by
Aurelien Jarno <aurelien@aurel32.net>

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-08-27 18:59:58 -04:00
Andrei Emeltchenko c1724f65bf usb: bos: Add USB BOS descriptors API
Add API for USB BOS Descriptors.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-06-20 15:47:00 -04:00
Johann Fischer 085a8b75c5 usb: hid: fix write to interrupt IN endpoint
A HID application can no longer write to the default
interrupt IN endpoint because the addresses are assigned
dynamically. Add hid_int_ep_write() function  and leave
it to the hid-core to call the usb_write() with the correct
endpoint address.

fixes: #8424

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-06-16 11:46:56 +02:00
Johann Fischer 1237549082 subsys: usb: configure Interface descriptor at runtime
Introduce function to configure interface descriptor at runtime.
It is simple to leave the corresponding function to configure the
interface descriptor and fix bInterfaceNumber and iInterface values,
for example.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-06-15 11:02:05 +02:00
Johann Fischer bf332d0004 subsys: usb: validate and update endpoint address
Add the routine to validate endpoint address and update the endpoint
descriptors and usb_ep_cfg_data at runtime.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-06-15 11:02:05 +02:00