Commit graph

630 commits

Author SHA1 Message Date
chemicstry
bd741a4019 Add comments to watchdog example 2022-07-10 21:08:30 +03:00
chemicstry
bd01e90bfa Implement IWDG timeout calculation 2022-07-10 20:38:30 +03:00
huntc
8785fbc6f1 Trait for UsbSupply
Eliminated a signal by using a simpler trait method that returns whether VBus power is available. Also includes a UsbSupply that can be signalled for use with the nRF softdevice. Includes the requirement for waiting for power to become available.
2022-07-09 17:57:31 +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
Ulf Lilleengen
6f425d7721 Use correct chip family name for example 2022-07-05 13:17:55 +02:00
Ulf Lilleengen
daf3ea24d7 Document configuration options and handle optional downlink 2022-07-04 10:33:29 +02:00
Ulf Lilleengen
7b35b4ebee Fix RAM origin copy paste from nrf 2022-06-29 19:14:07 +02:00
Ulf Lilleengen
f1f90b17b5 Add build.rs to detect armv6 2022-06-27 14:24:19 +02:00
Ulf Lilleengen
776be79f7b Move bootloader main to examples
This should remove some confusion around embassy-boot-* being a library
vs. a binary. The binary is now an example bootloader instead.
2022-06-24 19:56:15 +02:00
bors[bot]
84628d36cf
Merge #826
826: Bump bxcan version r=chemicstry a=chemicstry



Co-authored-by: chemicstry <chemicstry@gmail.com>
2022-06-22 23:48:45 +00:00
chemicstry
88c3737722 Simplify example 2022-06-23 02:30:55 +03:00
chemicstry
3cdd8c1aeb Fix PWM for advanced timers 2022-06-23 02:27:39 +03:00
chemicstry
31177d994f Fix example 2022-06-23 02:01:23 +03:00
bors[bot]
9721b2bf5b
Merge #817
817: Added a pubsub channel implementation r=lulf a=diondokter

This is similar to Tokio's Broadcast channel, except that it doesn't allocate.

The publishers and subscribers are dynamic. They use an &dyn channel reference because it's really annoying to have to specify the mutex and const generics every time.
Do we need fully generic types as well?

Co-authored-by: Dion Dokter <diondokter@gmail.com>
Co-authored-by: Dion Dokter <dion@tweedegolf.com>
2022-06-21 20:04:27 +00:00
Dion Dokter
78c546f356 Added example and some defmt 2022-06-21 15:47:20 +02:00
Dario Nieuwenhuis
6852e05c59
Merge pull request #822 from embassy-rs/remove-authors
Remove the authors field from Cargo.tomls
2022-06-18 17:33:29 +02:00
Dario Nieuwenhuis
3fd4ee34ec
Merge pull request #821 from embassy-rs/defmt-trace
Add env DEFMT_LOG=trace to all examples.
2022-06-18 02:24:25 +02:00
Dario Nieuwenhuis
1f746e0939 Remove the authors field from Cargo.tomls
It currently contains whoever was first to write some code for the crate,
even if many more people have contributed to it later.

The field is "sort of" deprecated, it was made optional recently:
https://rust-lang.github.io/rfcs/3052-optional-authors-field.html

Due the the reasons listed there I believe removing it is better than
setting it to generic fluff like "The Embassy contributors".
2022-06-18 02:16:40 +02:00
Dario Nieuwenhuis
88e36a70bd
Update to 2021 edition. (#820) 2022-06-18 02:15:48 +02:00
Dario Nieuwenhuis
dd99356062 Add env DEFMT_LOG=trace to all examples. 2022-06-18 01:59:12 +02:00
Dario Nieuwenhuis
b585d54712
Update rust nightly. (#819) 2022-06-18 01:44:02 +02:00
Dario Nieuwenhuis
a8703b7598 Run rustfmt. 2022-06-12 22:22:31 +02:00
bors[bot]
fff0a03fe0
Merge #806
806: Add embassy-cortex-m crate. r=Dirbaio a=Dirbaio

- Move Interrupt and InterruptExecutor from `embassy` to `embassy-cortex-m`.
- Move Unborrow from `embassy` to `embassy-hal-common` (nothing in `embassy` requires it anymore)
- Move PeripheralMutex from `embassy-hal-common` to `embassy-cortex-m`.

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-06-12 19:49:15 +00:00
Dario Nieuwenhuis
5085100df2 Add embassy-cortex-m crate.
- Move Interrupt and InterruptExecutor from `embassy` to `embassy-cortex-m`.
- Move Unborrow from `embassy` to `embassy-hal-common` (nothing in `embassy` requires it anymore)
- Move PeripheralMutex from `embassy-hal-common` to `embassy-cortex-m`.
2022-06-12 21:45:38 +02:00
huntc
99d19c7dcf Rename channel to mpmc
I've renamed the channel module for the MPMC as mpmc. There was a previous debate about this, but I feel that the strategy here avoids importing `channel::channel`. The change leaves `signal::Signal`, but I think that's ok. It is all a bit subjective of course. The bottom line for me is that I really like the term mpmc - it means something to me and aligns with broader naming e.g. in Tokio.
2022-06-12 15:16:56 +10:00
Dario Nieuwenhuis
db344c2bda
common/PeripheralMutex: remove unsafe API. (#802)
Following the project's decision that "leak unsafe" APIs are not marked as "unsafe",
update PeripheralMutex to accept non-'static state without unsafe.

Fixes #801
2022-06-09 21:28:13 +02:00
Dario Nieuwenhuis
3e4bead321 stm32: add USB driver. 2022-06-07 03:29:00 +02:00
Dominic Clifton
1bad6a4989 Add example for using a Signal. 2022-06-06 11:54:01 +02:00
Dario Nieuwenhuis
1089674175 fix build adding missing time-tick feature. 2022-05-31 23:53:42 +02:00
Dario Nieuwenhuis
d13d893ff2 boot/stm32: autodetect thumbv6, remove cargo feature. 2022-05-31 23:52:27 +02:00
Will Glynn
962fabe5c9 examples/stm32*, tests/stm32: specify time-tick-32768hz 2022-05-31 16:14:23 -05:00
bors[bot]
70e4418df9
Merge #781 #785
781:  embassy-net v2 r=Dirbaio a=Dirbaio

- No more `dyn`
- It's no longer a global singleton, you can create muliple net stacks at once.
  - You can't tear them down though, the Device it still has to be `'static` due to restrictions with smoltcp's "fake GAT" in the Device trait. :(
- Removed `_embassy_rand` hack, random seed is passed on creation.



785: stm32: g0: add PLL clock source r=Dirbaio a=willglynn

STM32G0 SYSCLK can be sourced from PLLRCLK. Given that the HSI runs at 16 MHz and the HSE range is 4-48 MHz, the PLL is the only way to reach 64 MHz. This commit adds `ClockSrc::PLL`.

The PLL sources from either HSI16 or HSE, divides it by `m`, and locks its VCO to multiple `n`. It then divides the VCO by `r`, `p`, and `q` to produce up to three associated clock signals:

  * PLLRCLK is one of the inputs on the SYSCLK mux. This is the main reason the user will configure the PLL, so `r` is mandatory and the output is enabled unconditionally.
  * PLLPCLK is available as a clock source for the ADC and I2S peripherals, so `p` is optional and the output is conditional.
  * PLLQCLK exists only on STM32G0B0xx, and exists only to feed the MCO and MCO2 peripherals, so `q` is optional and the output is conditional.

When the user specifies `ClockSrc::PLL(PllConfig)`, `rcc::init()` calls `PllConfig::init()` which initializes the PLL per [RM0454]. It disables the PLL, waits for it to stop, enables the source oscillator, configures the PLL, waits for it to lock, and then enables the appropriate outputs. `rcc::init()` then switches the clock source to PLLRCLK.

`rcc::init()` is now also resonsible for calculating and setting flash wait states. SYSCLCK < 24 MHz is fine in the reset state, but 24-48 MHz requires waiting 1 cycle and 48-64 MHz requires waiting 2 cycles. (This was likely a blocker for anyone using HSE >= 24 MHz, with or without the PLL.) Flash accesses are now automatically slowed down as needed before changing the clock source, and sped up as permitted after changing the clock source. The number of flash wait states also determines if flash prefetching will be profitable, so that is now handled automatically too.

[RM0454]: https://www.st.com/resource/en/reference_manual/rm0454-stm32g0x0-advanced-armbased-32bit-mcus-stmicroelectronics.pdf

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
Co-authored-by: Will Glynn <will@willglynn.com>
2022-05-31 00:25:21 +00:00
Dario Nieuwenhuis
6320e30adf Update embedded-hal-async to 0.1.0-alpha.1 2022-05-29 22:34:08 +02:00
bors[bot]
82e873d920
Merge #783
783: Reimplement BufRead for BufferedUart r=Dirbaio a=chemicstry

The `AsyncBufRead` implementation for `BufferedUart` was removed in https://github.com/embassy-rs/embassy/pull/752, this PR reimplements it from `embedded-io`. This allows reading `BufferedUart` without copying slices.

Co-authored-by: chemicstry <chemicstry@gmail.com>
2022-05-27 16:03:19 +00:00
chemicstry
c3b899c470 Implement BufRead for nrf BufferedUarte 2022-05-26 23:15:06 +03:00
Henrik Alsér
e10fc2bada
Async shared bus for SPI & I2C + rename embassy-traits (#769)
* Rename embassy-traits to embassy-embedded-hal

* Rename embassy-traits to embassy-embedded-hal

* Add shared bus for SPI and I2C

* rustfmt

* EHA alpha 1

* Rename embedded-traits in examples

* rustfmt

* rustfmt

Co-authored-by: Henrik Alsér <henrik@mindbite.se>
2022-05-26 18:54:58 +02:00
chemicstry
667abe6d1d Simplify example 2022-05-26 14:11:15 +03:00
chemicstry
4b6162694a Fix removed space 2022-05-26 14:05:56 +03:00
chemicstry
1d951a54be Reimplement BufRead for BufferedUart 2022-05-26 14:02:55 +03:00
Dario Nieuwenhuis
a5aea995a8 WIP embassy-net v2 2022-05-25 19:56:22 +02:00
Dario Nieuwenhuis
d0fe9af458
Merge pull request #771 from embassy-rs/net-split
net: add split() to tcpsocket
2022-05-19 07:13:24 +02:00
Dario Nieuwenhuis
e3b8e35498 Make embassy-net nightly-only.
It's useless without async traits, so juggling the `nightly` feature
around is not worth the pain.
2022-05-19 06:15:01 +02:00
bors[bot]
7743b8e1ae
Merge #776
776: Automatically set ADC clock prescaler on v2 ADC to respect max frequency r=Dirbaio a=matoushybl



Co-authored-by: Matous Hybl <hyblmatous@gmail.com>
2022-05-19 04:00:23 +00:00
Dario Nieuwenhuis
47ceee47d5 Update embedded-io to 0.3 2022-05-19 00:36:18 +02:00
Matous Hybl
53f65d8b09 Automatically set ADC clock prescaler on v2 ADC to respect max frequency 2022-05-18 18:34:36 +02:00
Henrik Alsér
0be9184efc
Merge branch 'embassy-rs:master' into qdec 2022-05-12 15:24:46 +02:00
bors[bot]
30d4d0e9d7
Merge #763 #766
763: Misc USB improvements r=Dirbaio a=Dirbaio

The "simplify control in/out handlng" commit gives a -2kb code size improvement.

766: Make usb_serial examples work on windows r=Dirbaio a=timokroeger

Windows shows `error 10` when using CDC ACM on non composite devices.
Workaround is to use IADS:
https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
Co-authored-by: Timo Kröger <timo.kroeger@hitachienergy.com>
2022-05-12 13:04:29 +00:00
Timo Kröger
2a7afe4262 Make usb_serial examples work on windows
Windows shows `error 10` when using CDC ACM on non composite devices.
Workaround is to use IADS:
https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
2022-05-12 08:05:13 +02:00
Dario Nieuwenhuis
2e104170de usb: remove address arg from endpoint allocation. 2022-05-09 02:07:48 +02:00
Henrik Alsér
1ca5475010
Merge branch 'embassy-rs:master' into qdec 2022-05-07 09:47:29 +02:00
bors[bot]
a4bf190f2f
Merge #752
752: Replace embassy::io with embedded_io. r=Dirbaio a=Dirbaio

TODO:

- [x] Release embedded-io on crates.io
- [x] Remove git dep

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-05-06 23:54:07 +00:00
Dario Nieuwenhuis
931a137f8c Replace embassy::io with embedded_io. 2022-05-07 01:45:54 +02:00
Henrik Alsér
108a981360 Change example pins 2022-05-07 01:15:01 +02:00
Henrik Alsér
840bb2952e Add qdec module 2022-05-07 00:46:36 +02:00
Matous Hybl
118532278c Add H7 flash and bootloader support 2022-05-06 21:57:15 +02:00
Matous Hybl
6d56f772e1 Add F7 flash and bootloader support 2022-05-06 21:57:15 +02:00
Matous Hybl
4f5088d79d Add support for F3 flash 2022-05-06 21:57:15 +02:00
Dario Nieuwenhuis
fc32b3750c Remove embassy_hal_common::usb.
The replacement is `embassy-usb`. There's a WIP driver for stm32 USBD in #709,
there's no WIP driver for stm32 USB_OTG. This means we're left without
USB_OTG support for now.

Reason for removing is I'm going to soon remove `embassy::io`, and
USB uses it. I don't want to spend time maintaining "dead" code
that is going to be removed. Volunteers welcome, either to update
old USB to the new IO, or write a USB_OTG driver fo the new USB.
2022-05-04 01:41:37 +02:00
Dario Nieuwenhuis
a5f5c3a844 net: add functions to get current Eth and IP config 2022-05-02 16:19:34 +02:00
bors[bot]
d600f39260
Merge #743
743: Add PLL config support for F2 r=Dirbaio a=Gekkio

- minor changes to make the F2 RCC API a bit more flexible
- low-level PLL config with assertions based on datasheet specs. It shouldn't be very difficult to later add a "reverse API" where you pass the clocks you want to a function and it generates a `PLLConfig` struct for you
- PLL API tested on my custom board with 12 MHz HSE as source for PLL to generate max clocks for SYSCLK/AHB/APB/APB1/PLL48
- the example *should* work but is untested since I don't have the Nucleo board 😞 

Co-authored-by: Joonas Javanainen <joonas.javanainen@gmail.com>
2022-04-30 21:08:43 +00:00
Joonas Javanainen
e88559c5ca
Use defmt-friendly error handling 2022-04-30 11:41:17 +03:00
David Lenfesty
2e7b42fc5b embassy-stm32/eth: convert LAN8742 driver to generic SMI driver
SMI Ethernet PHYs all share a common base set of registers that can do
90% of all tasks. The LAN8742 driver used some vendor-specific
registers to check link negotiation status, but the need for that was
debatable, so I migrated it to a generic driver instead, anybody who
wants extra functionality can copy it and impl their own on top of it.
2022-04-30 04:49:24 +02:00
Joonas Javanainen
1d5f9b86fb
Add PLL example for F2 2022-04-29 18:21:41 +03:00
Ulf Lilleengen
b7e7211a20 Fix linker script for nrf bootloader example 2022-04-28 14:11:01 +02:00
Ulf Lilleengen
bd237a1f96 Allow using separate page sizes for state and dfu
* Less generics on bootloader. Keep PAGE_SIZE as a common multiple of
DFU and ACTIVE page sizes.
* Document restriction
* Add unit tests for different page sizes
2022-04-28 10:38:25 +02:00
Ulf Lilleengen
da61611f8f Add bootloader to CI 2022-04-27 15:17:18 +02:00
Ulf Lilleengen
484e0acc63 Add stm32 flash + bootloader support
* Add flash drivers for L0, L1, L4, WB and WL. Not tested for WB, but
should be similar to WL.
* Add embassy-boot-stm32 for bootloading on STM32.
* Add flash examples and bootloader examples
* Update stm32-data
2022-04-27 15:17:18 +02:00
bors[bot]
df814f9bbd
Merge #734 #735
734: executor: Add `Spawner::for_current_executor`. r=Dirbaio a=Dirbaio

This is needed to spawn non-Send tasks in an InterruptExecutor, after the fixes in #730 .

`@matoushybl` could you check if this works for your use case?

735: stm32: add stm32u5 GPDMA, SPIv4 support, add HIL tests. r=Dirbaio a=Dirbaio



Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-04-26 23:32:30 +00:00
Dario Nieuwenhuis
009bb8e4e1 stm32: add stm32u5 GPDMA, SPIv4 support, add HIL tests. 2022-04-27 01:16:14 +02:00
Dario Nieuwenhuis
9e897cbea9 executor: Add Spawner::for_current_executor. 2022-04-26 19:08:18 +02:00
Ulf Lilleengen
2c0e28aa0c Update to released lorawan crates 2022-04-26 19:06:15 +02: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
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
Matous Hybl
945fa0871f Implement giant (chunked) DMA transfers for DCMI. 2022-04-25 14:30:43 +02: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
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
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
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
1bf7b4d6c3 usb: rename UsbDeviceBuilder -> Builder. 2022-04-16 04:14:20 +02: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
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
alexmoon
ff7c6b350e Remove channel and make run future cancelable 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
Dario Nieuwenhuis
e5a843dc06 net: auto-enable defmt in smoltcp using namespaced features. 2022-04-13 17:46:27 +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
Matous Hybl
371f3ef419 Add ADC support for H7 2022-04-12 22:25:00 +02:00
Philip A Reimer
8f6fccf012 fix clock in l4 rng example 2022-04-11 21:06:22 -06:00
Philip A Reimer
d8860c0b80 add stm32l4 hsi48 and usb example 2022-04-09 14:55:03 -06:00
alexmoon
e867364d42 Unify ReadError and WriteError into EndpointError 2022-04-09 01:48:17 +02:00
Ulf Lilleengen
86e52e67d0 Update to latest rust-lorawan version 2022-04-08 12:58:57 +02:00
Dario Nieuwenhuis
0c07d03754 Add missing stm32wl/stm32wb chips except stm32wle 2022-04-08 03:15:27 +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
alexmoon
6abbfa9a92 Async-ify Driver::enable and UsbDeviceBuilder::build 2022-04-07 10:51:26 -04:00
Matous Hybl
eb6910fa86 Reexport unborrow macro in HALs 2022-04-07 12:57:02 +02:00
bors[bot]
fee0aef076
Merge #696
696: Add async Mutex. r=Dirbaio a=Dirbaio

What it says on the tin :) 

It allows sharing data between tasks when you want to `.await` stuff while holding it locked.

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-04-06 10:20:43 +00:00
alexmoon
a1754ac8a8 embassy-usb-hid bug fixes 2022-04-06 05:38:11 +02:00
Dario Nieuwenhuis
b2e517bb28 usb/serial: add multitask example. 2022-04-06 05:38:11 +02:00
Dario Nieuwenhuis
3dbb7c9e15 usb/hid: add keyboard example. 2022-04-06 05:38:11 +02:00
Dario Nieuwenhuis
6d514a0b31 usb/hid: update for endpoint state changes. 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
alexmoon
99f95a33c3 Simplify hid output report handling 2022-04-06 05:38:11 +02:00
alexmoon
c309531874 Remove output() and split() methods from HidClass when there is no out endpoint, and route set_report requests for output reports to RequestHandler::set_report in that case. 2022-04-06 05:38:11 +02:00
alexmoon
a51de5a39a Remove the feature report reader 2022-04-06 05:38:11 +02:00
alexmoon
5ee7a85b33 Async USB HID class 2022-04-06 05:38:11 +02:00
Dario Nieuwenhuis
1672fdc666 usb-serial: make inner guts private. 2022-04-06 05:38:11 +02:00
Dario Nieuwenhuis
cdb7bae51a examples/nrf: don't build usb stuff in stable. 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
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
alexmoon
a22639ad92 Remove UnsafeCell from cdc_acm::Control 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
Dario Nieuwenhuis
a2f5763a67 usb: add add_class to builder, so that FooBarClass::new(&mut builder) can set up everything. 2022-04-06 05:38:11 +02:00
alexmoon
52c622b1cd Use trait objects instead of generics for UsbDevice::classes 2022-04-06 05:38:11 +02:00
alexmoon
bdc6e0481c Add support for USB classes handling control requests. 2022-04-06 05:38:11 +02:00
Dario Nieuwenhuis
9a6d11281d Add some comments on the example. 2022-04-06 05:38:11 +02:00
Dario Nieuwenhuis
0320500f0f Working CDC-ACM device->host 2022-04-06 05:38:11 +02:00
Dario Nieuwenhuis
77ceced036 Working CDC-ACM host->device 2022-04-06 05:38:11 +02:00
Dario Nieuwenhuis
37598a5b37 wip: experimental async usb stack 2022-04-06 05:38:11 +02:00
Dario Nieuwenhuis
6731948056 Add async Mutex. 2022-04-06 01:39:58 +02:00
Dario Nieuwenhuis
27a1b0ea73 Simpler Channel.
- Allow initializing in a static, without Forever.
- Remove ability to close, since in embedded enviromnents channels usually live forever and don't get closed.
- Remove MPSC restriction, it's MPMC now. Rename "mpsc" to "channel".
- `Sender` and `Receiver` are still available if you want to enforce a piece of code only has send/receive access, but are optional: you can send/receive directly into the Channel if you want.
2022-04-06 01:34:08 +02:00
Dario Nieuwenhuis
82803bffda Use embassy/defmt-timestamp-uptime in all examples. 2022-04-02 04:35:06 +02:00
Joonas Javanainen
a16fef21e1
Add blinky example for STM32F2
Default configuration is for NUCLEO-F207ZG board
2022-03-27 18:45:37 +03:00
chemicstry
f87c497315 Format 2022-03-17 00:03:24 +02:00
chemicstry
9d71acc49e Cleanup 2022-03-16 23:55:07 +02:00
chemicstry
224071f08e Add F7 example 2022-03-16 23:44:02 +02:00
chemicstry
f08f4df180 Cleanup 2022-03-16 20:33:46 +02:00
chemicstry
8a8e5c4b73 Fix SDMMC v2 and add H7 example 2022-03-16 20:20:39 +02:00
chemicstry
bf4a38ac06 Use RCC frequency instead of config 2022-03-16 19:09:37 +02:00
chemicstry
6d547b1143 SDIO working on stm32f4 2022-03-16 18:52:27 +02:00
Ulf Lilleengen
e09bde9345 Add support for splitting stm32 usart into TX and RX
* Keeps existing API for usart, but wraps it in Tx and Rx sub-types
* Adds split() method similar to nRF for getting indepdendent TX and RX
  parts
* Implements e-h traits for TX and RX types
* Add stm32h7 example
2022-03-15 10:35:37 +01:00
Dario Nieuwenhuis
9bad9365dc Update rust nightly, embedded-hal 1.0, embedded-hal-async. 2022-03-11 00:38:07 +01:00
bors[bot]
3047098c55
Merge #648 #656
648: Fix nRF Saadc continuous sampling r=Dirbaio a=huntc

Starting the sampling task prior to starting the SAADC peripheral can lead to unexpected buffer behaviour with multiple channels. We now provide an init callback at the point where the SAADC has started for the first time. This callback can be used to kick off sampling via PPI.

We also need to trigger the SAADC to start sampling the next buffer when the previous one is ended so that we do not drop samples - the major benefit of double buffering.

Given these additional tasks, we now simplify the API by passing in the TIMER and two PPI channels.

As a bonus, we provide an async `calibrate` method as it is recommended to use before starting up the sampling.

The example has been updated to illustrate these new features along with the simplified API.

The changes here have been tested on my nRF52840-DK.

656: stm32: Refactor DMA interrupts r=Dirbaio a=GrantM11235

Previously, every dma interrupt handler called the same `on_irq`
function which had to check the state of every dma channel.

Now, each dma interrupt handler only calls an `on_irq` method for its
corresponding channel or channels.

Co-authored-by: huntc <huntchr@gmail.com>
Co-authored-by: Grant Miller <GrantM11235@gmail.com>
2022-03-09 00:43:17 +00:00
Grant Miller
ed84d753c7 Update examples 2022-03-08 17:12:50 -06:00
huntc
3990f09b29 Simplifies the API by taking in the TIMER and PPI channels 2022-03-07 14:51:17 +11:00
huntc
98bdac51fe Improve nRF Saadc sampling
Starting the sampling task prior to starting the SAADC peripheral can lead to unexpected buffer behaviour with multiple channels. We now provide an init callback at the point where the SAADC has started for the first time. This callback can be used to kick off sampling via PPI.

We also need to trigger the SAADC to start sampling the next buffer when the previous one is ended so that we do not drop samples - the major benefit of double buffering.

As a bonus we provide a calibrate method as it is recommended to use before starting up the sampling.

The example has been updated to illustrate these new features.
2022-03-07 14:51:17 +11:00
Timo Kröger
4c30543938 [can] Do not use wildcard reexport for bxcan 2022-03-05 09:46:06 +01:00
Matous Hybl
a88c5e716e stm32: Register access for timers now doesn't require self 2022-02-28 16:20:42 +01:00
Cristian Eigel
f4ac3cf364 Improve logic for processing button events 2022-02-16 21:22:35 +01:00
Dario Nieuwenhuis
d9aec181a4 rp: impl eh1.0 blocking traits 2022-02-15 17:29:05 +01:00
bors[bot]
eb922c4655
Merge #608
608: stm32f4: add adc + example r=Dirbaio a=ain101

Example tested on stm32f407vg Discovery Board.
minimal adc: no vref, dma, complex sequence

Co-authored-by: Frederik <frederik@frederik.at>
2022-02-13 11:44:59 +00:00
Dario Nieuwenhuis
340eb4eead stm32: add rust stable support 2022-02-12 02:45:52 +01:00
bors[bot]
f2eb438905
Merge #615
615: rp: remove OptionalPin r=Dirbaio a=Dirbaio

Mirror of https://github.com/embassy-rs/embassy/pull/605 for rp2040

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-02-12 00:46:40 +00:00