Commit Graph

61 Commits

Author SHA1 Message Date
Graham Keeth d4d4c798a6 add usb audio, cdc, and midi stub files for doxy
- add stub files to relevant makefiles
- include <stdint.h> in respective headers to fix compilation
2020-11-28 22:13:25 +00:00
Fabio Pugliese Ornellas 2a4cf034c7 usb: dwc_otg: Add OTG_DSTS_SUSPSTS
Originally filed as: https://github.com/libopencm3/libopencm3/pull/1224

Reviewed-by: Karl Palsson <karlp@tweak.net.au>
2020-11-28 22:13:25 +00:00
Matthew Lai c49b4d35c2 stm32f7: added USB OTG FS/HS
Originally tracked at https://github.com/libopencm3/libopencm3/pull/958
While it doesn't work for everyone, this is clearly the basic first
steps required for any progress to be made.

Reviewed-by: Karl Palsson <karlp@tweak.net.au>
2020-11-28 22:13:25 +00:00
Devan Lai c13c2b3b3c usb: Allow registration of a single non-contiguous string descriptor for WinUSB
Classic WinUSB support is detected by probing for a string descriptor
at index 0xEE with a special string.
usbd_register_extra_string() allows registration of a string at this
index without having to provide 237 other string descriptors

Originally filed as https://github.com/libopencm3/libopencm3/pull/849

WCID reference: https://github.com/pbatard/libwdi/wiki/WCID-Devices
2020-11-28 22:13:25 +00:00
Manuel Bl e9c94760e6 stm32l4: enable USB OTG driver 2020-11-28 22:13:25 +00:00
Fabio Pugliese Ornellas 7daa6f15bf usb: define USB_CLASS_DFU 2020-01-12 20:31:26 +00:00
Karl Palsson df15b263d2 usb: hid: add a stub file for doxygen
Unlike with the doxygen source generation, we can't autoguess which of
the class files are eligible automatically.  Instead, make a stub hid
file, (which we can now start adding to, if desired) and include it in
all builds that include other class stubs.
2019-12-25 21:04:17 +00:00
Fabio Pugliese Ornellas f2f5083761 usb: Add more HID Class constants 2019-12-25 20:44:46 +00:00
Karl Palsson e8f03b4615 doc: usbd: Add missing / incorrect parameters.
Just basic documentation to clear up errors for starters.
2019-06-12 23:06:22 +00:00
Karl Palsson ce5d1ca9a2 doc: restore targets as pages.
You can't have two mainpage items, and the second was just being
ignored.  This restores them, which makes the left side list longer,
which we may or may not like, but it's at least how it was documented to
be.
2019-06-10 11:10:34 +00:00
Karl Palsson 795fe21860 usbd: document that only 8 eps are allowed.
The internal stack has a hard internal limit of 8, which is as many as
all supported devices support, but not as flexible as the arbitrary
addressing that USB actually allows.

At _least_ document this.

Fixes: https://github.com/libopencm3/libopencm3/issues/666
2019-06-05 21:48:28 +00:00
Karl Palsson 22754f0919 usb: provide lm4fusb driver reference
We provided references for all the others, provide it for the lm4f
driver too.
2018-08-27 15:11:32 +00:00
David Lamparter ebcf197810 usb: make usb_disconnect() weak
usb_disconnect() is board/platform specific for chips that don't have
built-in handling for this.  Allow the application to provide its own
version of usb_disconnect() to handle this.

See https://github.com/libopencm3/libopencm3/pull/924
2018-08-27 15:11:32 +00:00
David Lamparter 343cff4675 usb: make strings "const char * const *"
This allows the pointer table to be in Flash, by using
"static const char * const strings[] = { ... };"

See https://github.com/libopencm3/libopencm3/pull/924
2018-08-27 13:34:52 +00:00
Karl Palsson 6fa75afbc6 usb: add USB_REQ_TYPE_OUT to match USB_REQ_TYPE_IN
#defines are free.

Fixes https://github.com/libopencm3/libopencm3/issues/515
2018-08-20 23:53:07 +00:00
Karl Palsson f4bbe7c5bb usb: prevent registering duplicate config callbacks
Originally discussed at https://github.com/libopencm3/libopencm3/pull/722
2018-08-17 00:15:01 +00:00
Sebastian Holzapfel dfc67c03dc usb audio: add descriptors for streaming feature units 2018-07-03 22:23:00 +00:00
Karl Palsson 54b117c5a5 usb: Use enumerated return codes
The enum usbd_request_return_codes has been available for some time.  It
should be used internally, not just by users of this code.
2018-03-02 22:42:05 +00:00
Sebastian Holzapfel 995d19ebfd efm32hg: usb: add usb support 2018-03-02 22:42:05 +00:00
Sebastian Holzapfel a2ee90fbfe usb: stm32fx07 -> usb_dwc_common
The stm32fx07 is common DesignWare IP, used in both STM32 and EFM32 chips.
Rename the files to make this more clear, and easier to use in other
targets.
2018-03-02 22:42:05 +00:00
WGH f59d47cbd1 docs: usb: clarify usbd_register_control_callback()
Expand notes on when the control callbacks must be registered.

Reviewed-by: Karl Palsson <karlp@tweak.net.au>
2018-01-04 17:01:48 +00:00
Karl Palsson 9e36b8f29c usb: improve c++ compatiblity
Extract the definition of the usb_interface internal data to allow
easier integration with c++ code.

Fixes: https://github.com/libopencm3/libopencm3/issues/762
2017-06-08 23:01:45 +00:00
Anatol Pomozov ae41782e1a Fix misspellings using codespell tool 2016-03-08 08:52:54 -08:00
Kuldeep Singh Dhaka 57c7ba3283 usb: Remove unused "usbd_cable_connect" function definition.
It's not used anywhere, and if this sort of api becomes needed, it can be
designed cleanly and finished.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2016-02-29 20:58:47 +00:00
Piotr Esden-Tempski b1049f9a6f [Style] Stylefix sweep over the whole codebase. 2015-12-14 22:57:15 +01:00
Kuldeep Singh Dhaka 77354cb371 Inital support for EFM32LG 2015-12-13 19:56:19 +01:00
fenugrec c899273c62 usb: Improved comments of USB API
usbd.h: more comments for bmRequestType and bmAttributes bitfield macros
usbd.h: migrated and added API doxyblocks from implementations (*.c)
2015-10-14 20:48:26 +00:00
Karl Palsson 7814d06095 usb: control complete callback has no return value
It's never used, so let's make it void to avoid any confusion.
It was also an unintentional change from void to int in 4b89272
2015-10-14 10:04:37 +00:00
Karl Palsson f5eb96caf3 usb: Add st_usbfs_v2 for f0/l0 devices
Based on previous work, add a new driver for the v2 usb peripheral found on
stm32f0 and l0 devices.

Correspondingly, add a usb gadget zero test suite for the f0.  L0 device level
code isn't yet ready, but will add the test case when it moves in.

Work by Frantisek Burian, Kuldeep
Singh Dhaka, Robin Kreis, fenugrec and zyp on irc, and all those forgotten.
2015-10-03 02:03:58 +00:00
Karl Palsson e121243ce2 usb: extract ST USB FS peripheral core. [BREAKING CHANGE]
The breaking changes here changes in header location, and changes in driver
name passed down to the usb stack.

Changes affect: stm32f102/f103, stm32l1, and some f3 parts

* instead of the confusingly generic "usb" use the name "st_usbfs" for the USB
  Full speed peripheral ST provides in a variety of their stm32 products.
  Include directives should change as:
      #include <libopencm3/stm32/usb.h> => <libopencm3/stm32/st_usbfs.h>

* instead of the confusingly specific "f103" name for the driver, use
  "st_usbfs_v1"  [BREAKING_CHANGE]

  Instead of:
    usbd_init(&stm32f103_usb_driver, .....) ==>
    usbd_init(&st_usbfs_v1_usb_driver, .....) ==>

The purpose of these changes is to reduce some confusion around naming, but
primarily to prepare for the "v2" peripheral available on stm32f0/l0 and some
f3 devices.

Work by Frantisek Burian, Kuldeep Singh Dhaka, Robin Kreis, fenugrec and zyp
on irc, and all those forgotten.
2015-10-03 01:32:34 +00:00
Kuldeep Singh Dhaka 4b892724cf usb: provide typedefs for all the function callbacks.
This makes it easier to read for most people, and makes it substantially
easier to review changes in the function signatures themselves at a
later date.
2015-07-29 13:52:00 +00:00
Karl Palsson 4f5863e372 usb: add endpoint address calculation macros
Some people find it easier to read without the direction bit included.
2015-04-23 15:17:49 +00:00
Andrey Smirnov db58d5ae82 Add provisions to support multiple altsettings
This commit implements the support for one interface to have multiple
altsettings. It also adds hook that user can use to perform actions
when the alsetting switch is performed by host.

Changes:
* For backward compatibility, placed a pointer instead of allocating memory for whole interface struct.
* Always execute callback (even if the current interface alternate-settings matches).
* Multiple configuration support.

Signed-off-by: Kuldeep Singh Dhaka <kuldeepdhaka9@gmail.com>
2015-03-30 00:07:32 +00:00
Daniel Thompson e3b8adec10 usb: Support for MIDI class devices
Provides all of the config descriptors for MIDI class devices together
with a sub-set of the audio class sufficient to put together a full
fledged MIDI device.
2014-12-18 22:50:27 +00:00
Daniel Thompson d3aa579e0a usb: Support for class specific endpoint descriptors.
Extends struct usb_endpoint_descriptor to make it possible to provide
the USB host with class-specific extensions to endpoint descriptors.

The approach taken, based on extra and extralen and removing the sizeof()
from USB_DT_ENDPOINT_SIZE, is identical to the approach used to add
class-specific extensions to interface descriptors. All libopencm3-examples
use the USB_DT_ENDPOINT_SIZE (rather than directly using sizeof) so there
should be no compatibility problems resulting from this change.
2014-12-18 22:50:27 +00:00
Frantisek Burian 4d28c1b849 USB: Fix definition of function according to previous commit. 2014-07-14 14:50:07 +02:00
Pavol Rusnak 806ebb18fa add MSC (Mass Storage Class) support 2014-07-03 18:46:55 +02:00
Karl Palsson 5830a1ee8a usb-cdc: Add enums for parity/stop bit definitions
Sourced from the lm4f usb-cdcacm example, and verified against the USB CDC 1.2
standard document.  (And the 1.1 doc for good luck)
2014-01-22 20:24:04 +00:00
Piotr Esden-Tempski cabbd21329 Reverted the __packed and __aligned change.
We should not add compiler extensions, it is not our job. We are not a
selfcontained project as kernel is so we should not introduce things
like this.

If we need to add some abstraction for this in the future to support
compilers doing these things differently then we will do that the same
way we dealt with the depricated attribute.
2013-06-13 10:29:43 -07:00
Piotr Esden-Tempski 39fa9e4c58 Stile fixes run, 80 char boundry. 2013-06-12 21:07:35 -07:00
Piotr Esden-Tempski 34de1e776e Changed to use stdint types. 2013-06-12 19:11:22 -07:00
Piotr Esden-Tempski 7df63fcae0 First coarse run to fix coding style in locm3.
Added --terse and --mailback options to the make stylecheck target. It
also does continue even if it enounters a possible error.

We decided on two exceptions from the linux kernel coding standard:
- Empty wait while loops may end with ; on the same line.
- All blocks after while, if, for have to be in brackets even if they
  only contain one statement. Otherwise it is easy to introduce an
  error.

Checkpatch needs to be adapted to reflect those changes.
2013-06-12 18:22:56 -07:00
Andrey Smirnov 113e5c22e6 Change the way buffer for control requests data is allocated
Current way of having a globally, but weakly defined static buffer has
several shortcomings:
 - It forces user to have a certain "magic" byte array variable if
   they want to have a control buffer of different size.
 - Having a globally defined static array and a separate function to
   tell USB core about its size is error prone.
 - Its inner workings are not easily understandable form cursory look
   at API and one needs to go and look at the implementation code to
   connect all the pieces into a solid picture of how it works

This commit adds two parameters to 'usbd_init' call that allow user to
specify the pointer to the area of memory and a size of that memory
which would be used by the USB core to store the data received during
DATA stage of control requests. This approach, while further
complicating the prototype of 'usbd_init', provides user with more
flexibility allowing for any custom area of memory of any size to be
used as control buffer. It also forces user to provide both address
and memory size at the same time thus avoiding the possibility of user
redefining 'usbd_control_buffer', but not calling
'usbd_set_control_buffer_size' after that.
2013-04-25 17:24:27 -07:00
Ken Sarkies 1374d2622b Place generic USB header and source files into the documentation tree. 2013-04-19 10:26:01 +09:30
Jeff Ciesielski db35fbb7ba Merge branch 'master' of git://github.com/libopencm3/libopencm3 into upstream-merge 2012-11-13 13:13:40 -08:00
Andrey Smirnov 720e85f850 Further re-factor USB string handling code
This commit refactors USB string code, making it, hopefully, less
buggy and more easier to understand. It also removes "magic" bit
manipulation and "magic" numbers;
2012-11-07 11:30:44 -08:00
Andrey Smirnov c5c4db0196 Extend control hook framework
This commits adds a new error code that can be return from a
registered control callback: USBD_REQ_NEXT_CALLBACK. This return code
signifies that the callback is done processing the data successfully,
but user would like to have all matching callbacks down the callback
chain to be executed too.

This change allows for example to intercept standard requests like
GET_DESCRIPTOR, do some small action upon receiving of one, but still
have the standard callback executed and do it's job. This way user
doesn't have to re-implement standard GET_DESCRIPTOR functionality if
they want to intercept that request to do some small thing.
2012-11-07 10:33:51 -08:00
Andrey Smirnov 7a5da60e26 Change USB strings handling code
This commit add an extra field to the _usbd_device, that allows to
keep track of the number of USB strings  which allows simplify
boundaries checking code in usb_standard_get_descriptor.

This commit also changes the index base for strings in
usb_standard_get_descriptor which allows to get rid of necessity to
have a dummy one-character string in a strings array.
2012-11-06 16:46:55 -08:00
Jason Kotzin e8ec29e636 Adding vendor class definition 2012-09-13 10:43:35 -07:00
Jason Kotzin 34beeae925 USB core updated for reentrance based on Christian Cier-Zniewski's branch 2012-09-13 10:43:35 -07:00