Commit Graph

57 Commits

Author SHA1 Message Date
Dario Nieuwenhuis
3af991ab63 usb: unify ControlHandler+DeviceStateHandler, route all control requests to all handlers.
- Allows classes to handle vendor requests.
- Allows classes to use a single handler for multiple interfaces.
- Allows classes to access the other events (previously only `reset` was available).
2023-02-08 00:17:08 +01:00
Dario Nieuwenhuis
1d841cc8ac usb: make max interface count configurable at compile time. 2023-02-08 00:16:04 +01:00
alexmoon
9f9230ae7a Convert MS OS descriptor builder to a writer API
This brings it inline with the other embassy-usb descriptor APIs and allows it to integrate well with the Builder to allow class constructors to add MS OS descriptors.

Also adds a `usb_serial_winusb` example to demonstrate how to use the API.
2023-02-07 14:24:35 -05:00
Matt Ickstadt
f5ff3c4ac3 usb: add support for MS OS Descriptors 2023-02-07 14:24:35 -05:00
Dario Nieuwenhuis
ca10fe7135 usb: docs 2023-01-31 22:27:19 +01:00
chemicstry
ce842fe28c Refactor embassy-usb address handling to allow reordering of status resoponse 2023-01-11 17:47:12 +01:00
Dario Nieuwenhuis
f27a47a37b usb: move classes into the embassy-usb crate. 2022-09-26 13:00:21 +02:00
Dario Nieuwenhuis
7f7c14b7bc usb: split driver trait to separate crate. 2022-09-26 12:29:27 +02:00
Alex Martens
a45fb2d718 usb: fix compile errors with the log feature 2022-09-24 09:42:06 -07:00
Dario Nieuwenhuis
897b72c872 Update Rust nightly.
Removes feature(generic_associated_types)
2022-09-22 16:38:14 +02:00
Dario Nieuwenhuis
598689ef43 futures: move select* and join* to separate modules. 2022-08-29 01:00:22 +02:00
Dario Nieuwenhuis
21072bee48 split embassy-util into embassy-futures, embassy-sync. 2022-08-22 22:18:13 +02:00
Dario Nieuwenhuis
a0f1b0ee01 Split embassy crate into embassy-executor, embassy-util. 2022-07-29 23:40:36 +02:00
huntc
8d71a358c8 Build in a new Unpowered state
Replaces the sub-state of representing being being available. Power states also now set enable/disable directly too, which simplifies code.
2022-07-08 15:30:15 +10:00
huntc
4a8f117f25 Puts in the machinery to handle power detected/removed 2022-07-07 10:08:57 +10:00
huntc
c46e9b6cfc Introduces EnabledUsbDevice
EnabledUsbDevice is a wrapper around the UsbDevice where their enablement is also subject to external events, such as POWER events for nRF. It is introduced generically to support other platforms should they also require external signalling for enablement.
2022-07-07 10:08:57 +10:00
Dario Nieuwenhuis
a8703b7598 Run rustfmt. 2022-06-12 22:22:31 +02:00
Dario Nieuwenhuis
a7383840e7 usb: make ControlPipe accept, reject async. 2022-05-30 00:35:27 +02:00
Dario Nieuwenhuis
883e28a0fb usb: add first, last params to ControlPipe data_in, data_out. 2022-05-30 00:08:28 +02:00
Dario Nieuwenhuis
98d8c9373d usb: delay bus.set_address() to after ending the control transfer. 2022-05-30 00:03:36 +02:00
Dario Nieuwenhuis
5fd55f9529 usb: parse request in embassy-usb instead of the driver. 2022-05-12 18:14:48 +02:00
Dario Nieuwenhuis
6af5f8eb2d usb: merge alloc_control_pipe and into_bus into start.
This prevents calling `alloc_control_pipe` twice at compile time, which was
always an error.
2022-05-10 17:30:07 +02:00
Dario Nieuwenhuis
02ae1138e1 usb: merge Control logic into main code.
Now that control stuff is called from just one place, there's
no need to keep it as a separate struct.
2022-05-09 03:43:24 +02:00
Dario Nieuwenhuis
7ed462a657 usb: simplify control in/out handlng, calling response from a single place. 2022-05-09 02:11:02 +02:00
Dario Nieuwenhuis
0476f6b55b usb: add support for custom string descriptors. 2022-04-23 04:40:57 +02:00
Dario Nieuwenhuis
092c2b7dfe usb: builtin handling of interface alternate settings
The stack reads its own descriptors to figure out which endpoints
are used in which alt settings, and enables/disables them as needed.

The ControlHandler has a callback so it can get notified of alternate
setting changes, which is purely informative (it doesn't have to do anything).
2022-04-23 01:11:10 +02:00
Dario Nieuwenhuis
1bf7b4d6c3 usb: rename UsbDeviceBuilder -> Builder. 2022-04-16 04:14:20 +02:00
alexmoon
b0725c14d3 Split UsbDevice::run into run and run_until_suspend 2022-04-13 16:04:31 -04:00
alexmoon
ff7c6b350e Remove channel and make run future cancelable 2022-04-13 14:55:02 -04:00
alexmoon
1d875fab2d Use embassy::util::select3 2022-04-13 14:55:02 -04:00
alexmoon
2915e858ba Make Driver::disable async and fix comment 2022-04-13 14:55:02 -04:00
alexmoon
7fde3abd5d Remote wakeup bug fixes 2022-04-13 14:55:02 -04:00
alexmoon
f5656e3544 Add DeviceStateHandler, DeviceCommand channel, and remote wakeup support 2022-04-13 14:55:02 -04:00
alexmoon
6abbfa9a92 Async-ify Driver::enable and UsbDeviceBuilder::build 2022-04-07 10:51:26 -04:00
Dario Nieuwenhuis
f6d11dfba5 usb: fix slow enumeration with EP0 max_packet_size of 8 or 16. 2022-04-06 05:38:11 +02:00
alexmoon
2ce435dc34 Add basic device state handling for endpoints. 2022-04-06 05:38:11 +02:00
Dario Nieuwenhuis
8fe3b44d82 usb: log on reset, resume, suspend 2022-04-06 05:38:11 +02:00
Dario Nieuwenhuis
522a87ae42 usb: centralize all control logging in control.rs 2022-04-06 05:38:11 +02:00
alexmoon
f5ba022257 Refactor ControlPipe to use the typestate pattern for safety 2022-04-06 05:38:11 +02:00
alexmoon
77e0aca03b Move data chunking from the driver to the lib 2022-04-06 05:38:11 +02:00
Dario Nieuwenhuis
a435d78cf7 usb: cleanup and simplify error handling. 2022-04-06 05:38:11 +02:00
Dario Nieuwenhuis
60d3d11197 usb: cleanup logging. 2022-04-06 05:38:11 +02:00
Dario Nieuwenhuis
d1e4b3d7d5 usb: add -usb-serial crate, fix warnings and stable build. 2022-04-06 05:38:11 +02:00
alexmoon
d40ebcccf6 Add handlers for standard reqs to ControlHandler 2022-04-06 05:38:11 +02:00
alexmoon
13370c28db Add a control_buf to UsbDevice 2022-04-06 05:38:11 +02:00
alexmoon
c53bb7394a Switch to ControlHandler owned bufs for control_in() 2022-04-06 05:38:11 +02:00
Dario Nieuwenhuis
e99a3a1da4 usb: simplify buffer handling for Control IN transfers. 2022-04-06 05:38:11 +02:00
Dario Nieuwenhuis
bfce731982 usb: nicer names for control structs. 2022-04-06 05:38:11 +02:00
Dario Nieuwenhuis
2b547f311e usb: move all control-related stuff to mod control. 2022-04-06 05:38:11 +02:00
Dario Nieuwenhuis
15cc97d794 usb: associate ControlHandlers with interfaces, automatically route requests. 2022-04-06 05:38:11 +02:00