Commit Graph

132 Commits

Author SHA1 Message Date
dragonmux
484bfee238 usb/dwc: const-correctness improvements 2025-07-11 20:26:35 -07:00
dragonmux
adb4f73125 usb/dwc: Fixed a whole lot of constants issues in the common header 2025-07-11 20:26:35 -07:00
dragonmux
6b4592c82d usb/dwc: Corrected how interrupts are handled for the H7's DWC2 so that setup and out packets are properly acknowledged 2025-07-11 20:26:35 -07:00
dragonmux
5e6c423100 usb/dwc: Corrected how packets are read and unloaded from the DWC2 FIFOs on the H7 2025-07-11 20:26:35 -07:00
dragonmux
d9779685ae usb/dwc: Further implementation cleanup to fix integer conversions issues 2025-07-11 20:26:35 -07:00
dragonmux
7851b5e4a5 usb/dwc: Cleaned up in the endpoint setup implementation to improve const-ness 2025-07-11 20:26:35 -07:00
dragonmux
714e7b1c91 usb/dwc: Corrected how packets are written and loaded to the DWC2 FIFOs on the H7 2025-07-11 20:26:35 -07:00
dragonmux
7da573f9eb usb/dwc: Fixed some issues with how interrupts were being handled for the H7's DWC2 variant 2025-07-11 20:26:35 -07:00
dragonmux
76ba8900e3 usb/dwc: Fixed how the control endpoints are configured when built for STM32H7 2025-07-11 20:26:35 -07:00
dragonmux
22ef380fbf usb: Fixed up the number of endpoints defined in the control structures 2025-07-11 20:26:35 -07:00
dragonmux
e135b9000d usb: Cleaned up a little in the control endpoint implementation 2025-07-11 20:26:35 -07:00
dragonmux
61ed913de9 usb/dwc: Fixed the endpoint count being wrong on some devices as the DWC does not have a fixed endpoint count 2025-07-11 20:26:35 -07:00
dragonmux
cd906e97e4 usb/dwc: Fixed the definitions in the DWC common header not being wrapped in BEGIN_DECLS and END_DECLS 2025-07-11 20:26:35 -07:00
dragonmux
d7d6c3742c usb/usb_lm4f: Fixed the use of pointer maths on void pointers in the packet I/O code 2025-07-11 19:18:13 -07:00
dragonmux
6c6f926aee usb/usb_lm4f: Removed the unnecessary and standards-forbidden (void *) casts from the callback registrations 2025-07-11 19:18:13 -07:00
dragonmux
6ef29be9dd usb/usb_dwc_common: Removed the unnecessary and standards-forbidden (void *) casts from the callback registrations 2025-07-11 19:18:13 -07:00
dragonmux
2fca2a11e9 usb_control: Cleaned up the usb_control_send_chunk() logic slightly to make for easier reading 2025-07-11 19:14:29 -07:00
dragonmux
f2db2a1c61 usb/microsoft: Implemented support for sending the feature descriptors 2025-07-11 19:14:29 -07:00
dragonmux
901f920f6d usb/microsoft: Implemented support for sending more of the descriptor set tree 2025-07-11 19:14:29 -07:00
dragonmux
7aa5270809 usb_control: Implemented support for dispatching to the microsoft OS descriptors handler 2025-07-11 19:14:29 -07:00
dragonmux
9efcb120f7 usb: Begun implementing support for sending the microsoft OS descriptor set structures 2025-07-11 19:14:29 -07:00
dragonmux
8f69cc974d usb_standard: Added computation of the total BOS length to build_bos_descriptor 2025-07-11 19:14:29 -07:00
dragonmux
c0c642cb06 usb_control: Cleaned up in usb_control_request_dispatch() 2025-07-11 19:14:29 -07:00
dragonmux
b7ddb7c7c0 usb: Implemented support for sending the Microsoft OS-specific descriptor component of a platform capability descriptor 2025-07-11 19:14:29 -07:00
dragonmux
1bc180c639 usb_standard: Implemented support for sending out what we have so far of a BOS descriptor 2025-07-11 19:14:29 -07:00
dragonmux
60ff345798 usb: Begun implementing support into the USB device machinary for BOS descriptors 2025-07-11 19:14:29 -07:00
dragonmux
1d97cbf6e1 usb: Begun implementing support for Binary Object Stores and their capability descriptors 2025-07-11 19:14:29 -07:00
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
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
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
Karl Palsson
1f359e0cb8 doc: efm32: tag USB files for doxygen generation 2019-06-25 21:15:19 +00:00
Karl Palsson
26ab78a710 usb: fix race between setup complete and endpoint nak
See https://github.com/libopencm3/libopencm3/issues/873

Commentary describing this patch originally by zyp:

```
After looking further into it, I've concluded that my preliminary
analysis looks correct. The problem is that setting CNAK before
the SETUP complete event is received causes a race condition. The
SETUP callback is called when the SETUP packet event is received,
which means that setting CNAK from the callback is too early.

Originally the problem was that CNAK was set by ep_read() which is
called by the callback. #672 solved this by moving CNAK out of
ep_read() and calling it after the SETUP complete event is received
instead.

The regression by #785 is caused by the introduction of flow control
calls into the SETUP callback. They also set CNAK.

To solve this properly, I propose changing the event handling code
to only call the SETUP callback after the SETUP complete event is
received. Unfortunately, this implies that the callback can't call
ep_read() itself anymore, because the packet has to be read out of
the FIFO before the SETUP complete event arrives. This implies a
change of the API between the hardware drivers and _usbd_control_setup().
```

L1 (st_usbfs) works and passes tests as before change
F4 (dwc_otg_fs) works and now passes tests. (yay)
LM4f still compiles, and has had the same style of implementation as
st_usbfs, however has not been tested on any hardware.
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
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
kbob
5160d7996c efm32: Split efm32/lg into /lg and /common.
Somewhat replaces some earlier work done by hg/lg, but much more
complete, so we kept it as is, because it's bringing in even more parts
after this.

Reviewed-by: Karl Palsson <karlp@tweak.net.au>
2018-04-27 21:36:42 +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
64a6f362b8 usb-msc: fix write acknowledgement bug
Fixes https://github.com/libopencm3/libopencm3/issues/409
2018-03-02 22:42:05 +00:00
Sebastian Holzapfel
f871e539ed usb-standard: fix alignment assumption for Cortex-M0 platforms 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
a0669421e1 usb-dwc: handle any-aligned buffers
This is required to support armv6m targets using this code.
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
Vegard Storheil Eriksen
58f2ee34fa usb: Ensure control events are handled in order
Use EP0 OUT flow control to NAK OUT packets when we're not yet expecting
any. This prevents the status OUT event from arriving while the control
state machine is still expecting the data IN completion event.
2017-06-08 23:01:45 +00:00
Jochen Hoenicke
8b99b56c59 stmfx07: usb: Clean up FIFO read/write macro usage.
Use REBASE(OTG_FIFO(endpoint)) to access the FIFO.
For the receive FIFO do not use the endpoint. There
is only one receive FIFO so giving the endpoint is
a no-op.
Get rid of REBASE_FIFO macro.
2017-03-30 21:48:07 +00:00
Jochen Hoenicke
0c1ff686ad stmfx07: usb: Enable ctrl_out only after done rcvd.
This fixes the problem where the first four bytes were skipped in
the fifo.
2017-03-30 21:48:07 +00:00
Jochen Hoenicke
94f92d54d6 stmfx07: usb: keep better track of rxbcnt
When reading a portion of the packet that is not divisible by 4 and
not equal to rxbcnt the count could get off, since 4 bytes are read
from the fifo in the last step but rxbcnt was only updated by the
number of bytes the caller requested.

We fix this by always subtracting four bytes (the number of bytes
read from the fifo) when we read a word from the fifo.  Care has
to be taken in the last step so that rxbcnt doesn't underflow (it
is an unsigned number).

Note that reading in several small chunks not divisible by 4 doesn't
work as the extra bytes read in the last step are always discarded.
2017-03-30 21:48:07 +00:00
Jochen Hoenicke
a4f1568b7d stmfx07: usb: flush txfifo if not empty after SETUP
After a SETUP packet on a control endpoint the transmit FIFO
should usually be empty.  If something bad happened, e.g. PC
and device got out of sync, we want to clear the fifo.
This should fix #668.
2017-03-30 21:48:07 +00:00
Jochen Hoenicke
973efabddb stmfx07: usb: poll DIEPINT before RXFLVL
This is to interrupt for setup sequences on IN packet before
checking for OUT packet received.  This fixes the problem that
usb_control_out stalls because we are not yet in STATUS_OUT phase.
Related to #668.
2017-03-30 21:48:07 +00:00
David Sidrane
cf80e2bd5e stm32f4: USB support for newer OTG cores
Support for the  conflicting bit definitions for vbus sensing on core id
version 0x2000+

Reviewed-by: Karl Palsson <karlp@tweak.net.au>
2017-01-10 22:32:20 +00:00
Karl Palsson
825b51a6a8 usb: dwc_otg: fix missing includes
Went awol merging something :(
(Yes, dwc_otg is theoretically shared with efm and co, but at present
it's still pretty much the stm32 version)

Fixes: 422d708384
2016-11-21 17:27:43 +00:00