Commit graph

2384 commits

Author SHA1 Message Date
bors[bot]
a39d796c3d
Merge #730
730: Executor and task macro fixes. r=Dirbaio a=Dirbaio

See individual commits.

bors r+

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-04-25 20:21:32 +00:00
Dario Nieuwenhuis
2b0e8a330b examples/nrf: add self_spawn example.
This serves as a compile-test of possible typecheck loops due to
TAIT shenanigans.
2022-04-25 22:19:40 +02:00
Dario Nieuwenhuis
c4cecec10c macros: isolate the TAIT into its own mod.
This fixes type inference issues due to the TAIT's defining scope
being the whole parent mod.
2022-04-25 22:18:52 +02:00
Dario Nieuwenhuis
b27feb0619 executor: fix unsoundness in InterruptExecutor::start.
The initial closure is not actually called in the interrupt, so this is
illegally sending non-Send futures to the interrupt.

Remove the closure, and return a SendSpawner instead.
2022-04-25 22:09:04 +02:00
Dario Nieuwenhuis
52ed08cf95 executor: remove useless not_send in SendSpwaner. 2022-04-25 16:38:56 +02:00
bors[bot]
97e24b0568
Merge #716
716: Implement giant (chunked) DMA transfers r=Dirbaio a=matoushybl

There is a breaking change in the Channel trait in the method `remaining_transfers()`, this method however hasn't been used anywhere in the codebase and the return type changed from u16 to u32, so all of the previous use cases should work.

Co-authored-by: Matous Hybl <hyblmatous@gmail.com>
2022-04-25 12:32:04 +00:00
Matous Hybl
945fa0871f Implement giant (chunked) DMA transfers for DCMI. 2022-04-25 14:30:43 +02:00
bors[bot]
a1746f4dda
Merge #717
717: WIP: USB CDC NCM (Ethernet over USB) r=Dirbaio a=Dirbaio

TODO:

- [x] Add support for string handling in `embassy-usb`, remove the MAC addr string hax
- [x] Harden parsing of incoming NTBs to avoid panics.
- [ ] Parse all datagrams in a NDP, not just the first. -- tricky, I've made it tell the host we support only one packet per NTB instead.
- [ ] Add support for all required control transfers. -- WONTFIX, seems no OS cares about those.
- [x] Works on Linux
- [x] Doesn't work on Android, make it work
- [x] Check if it works in Windows (Win10 has some sort of CDC NCM support afaict?) -- works on Win11, CDC-NCM not supported on Win10
- [x] Check if it works in MacOS (I don't know if it's supposed to) - WORKS

I won't add the `embassy-net` driver to `embassy-usb-ncm` for now because `embassy-net` buffer management will likely be refactored soon, so there's not much point to it.

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-04-24 20:47:37 +00:00
Dario Nieuwenhuis
d409026b95 examples/nrf: add product strings to all usb examples. 2022-04-24 22:46:45 +02:00
Dario Nieuwenhuis
d57fd87ba7 Add embassy-usb-ncm. Implements USBB CDC NCM (Ethernet over USB) 2022-04-24 22:44:52 +02:00
Dario Nieuwenhuis
50e1d257bd net: change listen() to accept(), which waits until the connection is established. 2022-04-24 04:35:29 +02:00
Dario Nieuwenhuis
b578e060d7
Merge pull request #729 from embassy-rs/update-nightly
Update Rust nightly.
2022-04-24 04:34:30 +02:00
Dario Nieuwenhuis
408617266e Update Rust nightly.
Fixes a new opaque type error in the task macro.
Full error is "opaque type's hidden type cannot be another opaque type from the same scope".
This got disallwed by the lazy-TAIT PR: https://github.com/rust-lang/rust/pull/94081

Sadly there's now some weird type inference errors with pre-lazy-TAIT
nightlies, so support for those is dropped.
2022-04-24 04:24:08 +02:00
Dario Nieuwenhuis
11143a1be1
Merge pull request #722 from embassy-rs/usb-altsettings
usb: builtin handling of interface alternate settings
2022-04-23 06:20:11 +02:00
Dario Nieuwenhuis
7778b79dc3 nrf: autoenable defmt in deps. 2022-04-23 06:03:38 +02:00
Dario Nieuwenhuis
0476f6b55b usb: add support for custom string descriptors. 2022-04-23 04:40:57 +02:00
Dario Nieuwenhuis
7c6a88f3dd usb: set the interface handler in InterfaceBuilder. 2022-04-23 01:29:19 +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
bors[bot]
afb4f8623b
Merge #727
727: Switch to crates.io embedded-hal, embedded-hal-async. r=Dirbaio a=Dirbaio

This temporarily removes support for the async UART trait, since it's
not yet in embedded-hal-async.

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-04-22 18:15:05 +00:00
Dario Nieuwenhuis
3251a21fb7 Switch to crates.io embedded-hal, embedded-hal-async.
This temporarily removes support for the async UART trait, since it's
not yet in embedded-hal-async.
2022-04-22 19:58:24 +02:00
Dario Nieuwenhuis
ea0a701ebd
Merge pull request #725 from liigo/patch-1
remove description which not makes sense
2022-04-22 18:16:27 +02:00
Liigo Zhuang
b97592248a reword task finish and cancel 2022-04-22 15:10:59 +08:00
Dario Nieuwenhuis
f63813367b
Merge pull request #726 from danbev/time_driver_typo
Fix typo in driver.rs
2022-04-21 18:29:28 +02:00
Daniel Bevenius
db862a60ee Fix typo in driver.rs 2022-04-21 18:27:00 +02:00
Liigo Zhuang
a61daa9f7f
remove description which not makes sense 2022-04-21 17:17:01 +08:00
bors[bot]
de7dd59fa9
Merge #713
713: Bootloader external flash r=lulf a=lulf

Includes e-s and e-s-a impls for nrf QSPI

WIP: Working on testing it.

Co-authored-by: Ulf Lilleengen <ulf.lilleengen@gmail.com>
2022-04-20 06:21:51 +00:00
Ulf Lilleengen
2afff617f6 Support multiple flash instances in embassy-boot
* Add FlashProvider and FlashConfig traits to define flash
characteristics
* Use traits in bootloader to retrieve flash handles and for
copying data between flash instances
* Add convenience implementations for using a single flash instance.
2022-04-19 20:07:06 +02:00
bors[bot]
e2ed41b383
Merge #723
723: Add embedded-storage trait impls for QSPI r=Dirbaio a=lulf

* Adds implementations of embedded-storage and embedded-storage-async
for QSPI
* Add blocking implementations of QSPI
* Use blocking implementation in new() and embedded-storage impls
* Use async implementation in embedded-storage-async impls
* Add FLASH_SIZE const generic parameter
* Own IRQ in Qspi instance to disable it on drop.

Co-authored-by: Ulf Lilleengen <ulf.lilleengen@gmail.com>
2022-04-19 17:20:33 +00:00
Ulf Lilleengen
e966125d62 Add embedded-storage trait impls for QSPI
* Adds implementations of embedded-storage and embedded-storage-async
for QSPI
* Add blocking implementations of QSPI
* Use blocking implementation in new() and embedded-storage impls
* Use async implementation in embedded-storage-async impls
* Add FLASH_SIZE const generic parameter
* Own IRQ in Qspi to disable it on drop
2022-04-19 19:06:36 +02:00
Dario Nieuwenhuis
00c51c8fd5 More README fix. 2022-04-19 01:35:13 +02:00
Dario Nieuwenhuis
6c1dccf86e Readme formatting fix. 2022-04-19 01:34:39 +02:00
Dario Nieuwenhuis
a8b9593a9a Readme fix. 2022-04-19 01:32:09 +02:00
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