Commit Graph

3002 Commits

Author SHA1 Message Date
Dario Nieuwenhuis
19fa882d99 New README. 2022-04-19 01:31:20 +02:00
bors[bot]
0f1a364cd9
Merge #720
720: USB: New builder API  r=Dirbaio a=Dirbaio


    usb: improved descriptor building API
    
    The same API call allocates interfaces/endpoints/etc and writes their descriptors.
    This means less API calls, and less possibility to screw things up.
    
    DescriptorWriter is now private.


Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-04-16 02:32:35 +00:00
Dario Nieuwenhuis
50d257cc7c usb: improved descriptor building API
The same API call allocates interfaces/endpoints/etc and writes their descriptors.
This means less API calls, and less possibility to screw things up.

DescriptorWriter is now private.
2022-04-16 04:30:31 +02:00
Dario Nieuwenhuis
1bf7b4d6c3 usb: rename UsbDeviceBuilder -> Builder. 2022-04-16 04:14:20 +02:00
bors[bot]
1c9adec3c5
Merge #721
721: USB HID: simplify API r=Dirbaio a=Dirbaio

Following the discussion from #720  and [matrix](https://matrix.to/#/!YoLPkieCYHGzdjUhOK:matrix.org/$PcPr8E_JbodEPuUUKI2PzIC9sx7nF3y0kV2T5O4UWj8?via=matrix.org&via=converser.eu&via=braun-odw.eu), this is a second take on simplifying the HID API.

Split into a separate PR so it can be reviewed separately.

See individual commit messages for details.

cc `@alexmoon` 

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-04-16 01:55:21 +00:00
Dario Nieuwenhuis
f35bde684a usb-hid: add Config struct, to avoid too many params. 2022-04-16 02:07:03 +02:00
Dario Nieuwenhuis
c0de54a341 usb-hid: Simplify API.
- Renamed structs to HidReaderWriter, HidReader, HidWriter.
- Removed unused const generics on `State`.
- Simplified generics on `HidReaderWriter`.
  The class type previously was `HidClass<D, Driver<'d, USBD>, ReportReader<'d, Driver<'d, USBD>, OUT_N>, IN_N>`
  It's now `HidClass<D, Driver<'d, USBD>, IN_N, OUT_N>`. Note that the driver type `Driver<'d, USBD>` is no longer repeated.
- Constructors are now: `HidWriter::new()` for IN-only, `HidReaderWriter::new()` for IN+OUT. No complicated bounds.
- HidReaderWriter has all the methods from HidReader, HidWriter.
2022-04-16 01:59:40 +02:00
Dario Nieuwenhuis
94090e068e usb: fix wrong logging of CONTROL OUT data. 2022-04-15 18:45:52 +02:00
bors[bot]
3a90a8eb4a
Merge #711
711: Add DeviceStateHandler, DeviceCommand channel, and remote wakeup support r=Dirbaio a=alexmoon

Apologies for the size of this PR. Once I started getting into the Vbus power management side of my device I found a couple of areas of functionality missing from embassy-usb. Specifically, I need the application to be able to respond to changes in the USB device state in order to properly control the amount of power I'm drawing from Vbus. I also wanted to enable remote wakeup support for my device.

In order to enable device state monitoring, I've created a `DeviceStateHandler` trait and made it possible to pass in an optional reference a handler implementing that trait when creating the `UsbDeviceBuilder`.

Remote wakeup required a way to send commands to the bus which is exclusively owned by the `UsbDevice::run` method. This is the same problem we were discussing for enabling/disabling the device on Vbus power events. My solution is to allow an optional `Channel` to be provided to the `UsbDeviceBuilder` (via `UsbDeviceBuilder::new_with_channel`), allowing the application to send commands into the `run` method. Right now it supports enable, disable and remote wakeup commands.

Since there's now a way to dynamically enable and disable the device, I also added `Config::start_enabled` to control whether or not the `UsbDevice` should start in the enabled state. That also allowed me to make `UsbDeviceBuilder::build` sync again and move enabling the bus into `UsbDevice::run`.

This led to a few driver changes:
1. `Driver::enable` became `Driver::into_bus`
2. `Bus::enable`, `Bus::disable`, and `Bus::remote_wakeup` were added
3. I removed `Bus::reset`, `Bus::suspend`, and `Bus::resume` because they were only ever called based on the result of `Bus::poll`. It made more sense to me to have `Bus::poll` handle the driver-specific state management itself.

I've updated the `usb_hid_keyboard` example to take advantage of all these additional features.

Let me know what you think.

Thanks!


Co-authored-by: alexmoon <alex.r.moon@gmail.com>
2022-04-14 15:16:55 +00:00
alexmoon
b0725c14d3 Split UsbDevice::run into run and run_until_suspend 2022-04-13 16:04:31 -04:00
Dario Nieuwenhuis
391fdc097e
Merge pull request #718 from embassy-rs/net-fixes
Net fixes
2022-04-13 21:06:27 +02: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
3a30b08936 Remove dead code on nrf5340 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
Dario Nieuwenhuis
e5a843dc06 net: auto-enable defmt in smoltcp using namespaced features. 2022-04-13 17:46:27 +02:00
Dario Nieuwenhuis
0d3758ad6b net: make run() noreturn. 2022-04-13 17:27:20 +02:00
Dario Nieuwenhuis
2217de24c0 usb-hid: add embassy docs metadata. 2022-04-13 16:46:24 +02:00
bors[bot]
6d0e6d563d
Merge #714
714: add more clock options for l4 and l5 r=Dirbaio a=ant32

- added an assert so it panics if pll48div is not 48Mhz
- added MSI as a clock source for PLL
- removed hsi48 option for MCUs mentioned in l4 rcc presentation
- copied some code from l4 to l5, but don't have a way of testing it.

Co-authored-by: Philip A Reimer <antreimer@gmail.com>
2022-04-12 21:42:36 +00:00
bors[bot]
5d48153bd7
Merge #694
694: Add select, select3, select4. r=Dirbaio a=Dirbaio

The difference with those from the `futures` crate is they don't return the other partially-run futures, so they can work with `!Unpin` futures which makes them much easier to use.

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-04-12 21:27:13 +00:00
bors[bot]
77c2b151c2
Merge #715
715: stm32/dac: Check proper channel r=Dirbaio a=michalsrb

Small fix. Otherwise it panics when trying to use channel 1 if channel 2 does not exist.

Co-authored-by: Michal Srb <michalsrb@gmail.com>
2022-04-12 20:57:36 +00:00
bors[bot]
d8dd671522
Merge #699
699: Add ADC support for H7 r=Dirbaio a=matoushybl

Seems to work on H743, ADC1 works fine, but ADC3 has different ADC_COMMON block which stm32-data does't yet support, so measuring VREFINT or TEMP doesn't work. I'd like to discuss how adding support for the different ADC_COMMON could be done.

Co-authored-by: Matous Hybl <hyblmatous@gmail.com>
2022-04-12 20:39:47 +00:00
Matous Hybl
371f3ef419 Add ADC support for H7 2022-04-12 22:25:00 +02:00
Michal Srb
c1914a477d stm32/dac: Check proper channel 2022-04-12 12:49:06 +02:00
bors[bot]
ac3986e40e
Merge #712
712: Add types for channel dynamic dispatch r=lulf a=lulf

* Add internal DynamicChannel trait implemented by Channel that allows
  polling for internal state in a lock safe manner and does not require
  knowing the channel size.
* Existing usage of Sender and Receiver is preserved and does not use
  dynamic dispatch.
* Add DynamicSender and DynamicReceiver types that references the
  channel using the DynamicChannel trait and does not require the const
  generic channel size parameter.

Having the ability not know the channel size is very convenient when you don't want to change all of your channel using code when tuning the size. With this change, existing usage can be kept, and those willing to pay the price for dynamic dispatch may do so.

Co-authored-by: Ulf Lilleengen <lulf@redhat.com>
2022-04-12 09:55:33 +00:00
Philip A Reimer
8f6fccf012 fix clock in l4 rng example 2022-04-11 21:06:22 -06:00
Philip A Reimer
d90ecbbe40 add more clock options for l4 and l5 2022-04-11 19:11:02 -06:00
Ulf Lilleengen
cdf30e68eb Erase mutex type as well 2022-04-11 13:33:48 +02:00
Ulf Lilleengen
bc1dff34c0 Add types for channel dynamic dispatch
* Add internal DynamicChannel trait implemented by Channel that allows
  polling for internal state in a lock safe manner and does not require
  knowing the channel size.
* Existing usage of Sender and Receiver is preserved and does not use
  dynamic dispatch.
* Add DynamicSender and DynamicReceiver types that references the
  channel using the DynamicChannel trait and does not require the const
  generic channel size parameter.
2022-04-11 08:57:15 +02:00
bors[bot]
e844893095
Merge #710
710: add stm32l4 hsi48 and usb example r=Dirbaio a=ant32



Co-authored-by: Philip A Reimer <antreimer@gmail.com>
2022-04-09 23:57:18 +00:00
Philip A Reimer
d8860c0b80 add stm32l4 hsi48 and usb example 2022-04-09 14:55:03 -06:00
bors[bot]
cd6250986a
Merge #708
708: Unify ReadError and WriteError into EndpointError r=Dirbaio a=Dirbaio

Originally #698, got overwritten in a rebase I think.

Co-authored-by: alexmoon <alex.r.moon@gmail.com>
2022-04-09 00:06:44 +00:00
alexmoon
e867364d42 Unify ReadError and WriteError into EndpointError 2022-04-09 01:48:17 +02:00
bors[bot]
b2cdaa56c1
Merge #707
707: Add saadc::VddhDiv5Input r=Dirbaio a=alexmoon

Adds support for the VDDHDIV5 ADC input on newer nrf chips.

Co-authored-by: alexmoon <alex.r.moon@gmail.com>
2022-04-08 20:38:45 +00:00
alexmoon
9c6d49961b Add saadc::VddhDiv5Input 2022-04-08 13:41:21 -04:00
bors[bot]
e898b4e683
Merge #706
706: Update to latest rust-lorawan version r=Dirbaio a=lulf



Co-authored-by: Ulf Lilleengen <lulf@redhat.com>
2022-04-08 15:38:00 +00:00
Ulf Lilleengen
86e52e67d0 Update to latest rust-lorawan version 2022-04-08 12:58:57 +02:00
bors[bot]
3e45403a2a
Merge #705
705: Add stm32wlexx support r=Dirbaio a=Dirbaio

RCC is actually identical, other than removing multicore-related regs.

bors r+

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-04-08 01:44:22 +00:00
Dario Nieuwenhuis
8b757e1aec Add stm32wlexx support 2022-04-08 03:43:58 +02:00
Dario Nieuwenhuis
b40c8342ec
Merge pull request #704 from embassy-rs/stm32wlwb-more
Add missing stm32wl/stm32wb chips except stm32wle
2022-04-08 03:32:29 +02:00
Dario Nieuwenhuis
05fecb3def
Merge pull request #703 from embassy-rs/stm32l5
Add STM32L5 support.
2022-04-08 03:25:41 +02:00
Dario Nieuwenhuis
0c07d03754 Add missing stm32wl/stm32wb chips except stm32wle 2022-04-08 03:15:27 +02:00
Dario Nieuwenhuis
50ff63ab88 Add STM32L5 support. 2022-04-08 03:11:38 +02:00
bors[bot]
37da84129d
Merge #657
657: Async usb stack r=Dirbaio a=Dirbaio

TODO

- [x] Make it work on nRF
- [x] Add a way for classes to handle their own EP0 control requests - thanks `@alexmoon!`
- [x] Handle CONTROL OUT requests with data.
- [ ] Impl AsyncRead/AsyncWrite for CDC ACM -- will do later, it's not trivial
- [x] Cleanup unwraps/asserts/panics
- [x] Cleanup logs (make everything trace/debug, not info)
- [ ] Port synopsys-usb-otg
- [ ] Port stm32-usbd
- [ ] Add more classes? HID, MSD?


Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
Co-authored-by: alexmoon <alex.r.moon@gmail.com>
2022-04-07 23:03:39 +00:00
Dario Nieuwenhuis
9252e8bb88 Update cargo-batch. 2022-04-08 00:35:00 +02:00
bors[bot]
637ec36f9c
Merge #700
700: Add back support for cloning sender/receiver r=Dirbaio a=lulf

The automatic derive clone does not work because RawMutex is not Clone.

Co-authored-by: Ulf Lilleengen <lulf@redhat.com>
2022-04-07 19:27:36 +00:00
Dario Nieuwenhuis
d2494486d1
Merge pull request #701 from alexmoon/async-usb-stack
Async-ify Driver::enable and UsbDeviceBuilder::build
2022-04-07 19:55:00 +02:00
alexmoon
7f9dd1a37b Fix spurious ControlPipe::data_in errors 2022-04-07 10:54:21 -04:00