Commit Graph

30 Commits

Author SHA1 Message Date
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
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 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
Karl Palsson 3ed12b6fd9 usb: short control IN might need a ZLP
Control transfers can transfer less than was requested by the host in the
wLength field.  if this short transfer is a multiple of the endpoint's packet
size, a zero length packet must be sent.

Adds tests for a range of control transfer IN requests, and properly supports
this in the core.  Based heavily on work by Kuldeep Dhaka.

See https://github.com/libopencm3/libopencm3/pull/505
and https://github.com/libopencm3/libopencm3/pull/194 for original discussion.

Tested with stm32f4, stm32f103 and stm32l053.
2015-10-11 18:43:11 +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
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
Franck Jullien d6bad27735 Allow more than one usbd_register_set_config_callback
In a composite device if one want to separate code
for each interface, usbd_register_set_config_callback
can now register more than one callback.

Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
2014-07-14 14:04:58 +02: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
Ken Sarkies 1374d2622b Place generic USB header and source files into the documentation tree. 2013-04-19 10:26:01 +09:30
Piotr Esden-Tempski 80fd23580a Fix all warnings for stm32f1 lib. 2013-02-26 17:14:31 -08:00
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 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 34beeae925 USB core updated for reentrance based on Christian Cier-Zniewski's branch 2012-09-13 10:43:35 -07:00
Piotr Esden-Tempski 43561de329 License change of the library to LGPL, version 3 or later.
Agreed to by all the significant contributors to the library.
2012-03-02 14:44:49 -08:00
Mike Smith 7da1967056 Add an interface for soft disconnection, and hook it up in the F107 driver. 2012-02-12 15:00:08 -08:00
Gareth McMullin b05a5dcf2a Fixed some F105/F107 USB issues. Added user callback on SOF.
Made examples depend on lib.
2011-10-29 21:30:26 +13:00
Gareth McMullin ef0ff192f7 Added usbd_ep_nak_set() to force flow control on OUT endpoints. 2011-03-30 07:17:02 +13:00
Gareth McMullin e64a9d2bf9 Minor cleanup of usb. Template driver for STM32F107 added. 2011-02-10 19:58:51 +13:00
Gareth McMullin aac65d8560 Abstracted USB driver interface to to allow driver selection. 2011-01-30 17:04:56 +13:00
Uwe Hermann 18790a2454 More renames for libopenstm32 -> libopencm3. 2010-12-30 13:19:25 +01:00
Uwe Hermann b5727a6c73 USB: Cosmetics and coding-style fixes. 2010-12-29 18:00:32 +01:00
Uwe Hermann c39eb69e4d Replace uint8_t with u8 et al, fix whitespace. 2010-12-29 17:28:06 +01:00
Uwe Hermann 34fd228bf9 Move generic USB stuff to a subdir, dedupe .h files.
Adapt examples and the lib code accordingly.
2010-12-29 17:02:36 +01:00
Uwe Hermann f062777930 More whitespace fixes. 2010-12-29 16:43:26 +01:00
Gareth McMullin 7f002110dc Improved dispatching of user control callbacks.
Only cdc_acm example is updated.
2010-11-06 12:21:46 +13:00
Martin Mueller d6eacce827 add standard request 2010-11-04 00:44:47 +01:00
Uwe Hermann 6e090ccee1 Initial USB device stack for STM32.
Patch provided by Gareth McMullin <gareth@blacksphere.co.nz>,
thanks a lot!
2010-11-02 02:02:21 +01:00