Commit Graph

3199 Commits

Author SHA1 Message Date
bors[bot]
01e23bf9dd
Merge #1025
1025: Implement I2C timeouts, second attempt r=Dirbaio a=chemicstry

This is an alterrnative to #1022 as discussed there.

Timeouts are implemented using suggested `check_timeout: impl Fn() -> Result<(), Error>` function, which does not depend on `embassy-time` by default and is a noop for regular I2C.

This also adds `time` feature like in `embassy-nrf` to enable `embassy-time` dependencies. While at it, I also gated some other peripherals that depend on `embassy-time`, notably `usb` and (partially) `subghz`.

`TimeoutI2c` is currently only implemented for i2cv1, because i2cv2 has additional complications:
- Async methods still use a lot of busy waiting code in between DMA transfers, so simple `with_timeout()` will not work and it will have to use both types of timeouts. It could probably be rewritten to replace busy waits with IRQs, but that's outside the scope of this PR.
- I2C definition `I2c<'d, T, TXDMA, RXDMA>` is different from i2cv1 `I2c<'d, T>` making it hard to share single `TimeoutI2c` wrapper. A couple of options here:
  - Duplicate `TimeoutI2c` code
  - Add dummy `TXDMA`, `RXDMA` types to i2cv1 considering that in the future it should also support DMA

Co-authored-by: chemicstry <chemicstry@gmail.com>
2022-10-26 19:34:43 +00:00
bors[bot]
e5097a8866
Merge #959
959: Generic, executor-agnostic queue implementation r=ivmarkov a=ivmarkov

Hopefully relatively well documented.

Implementation relies on a fixed-size `SortedLinkedList` from `heapless`. (By default, for up to 128 timer schedules, but we can lower this number to - say - 64.)

As discussed earlier, on queue overflow, the `WakerRegistration` approach is utilized, whereas the waker that is ordered first in the queue is awoken to make room for the incoming one (which might be the waker that would be awoken after all!). Wakers are compared with `Waker::will_wake`, so the queue should actually not fill up that easily, if at all.

I've left provisions for the user to manually instantiate the queue using a dedicated macro - `generic_queue!` so that users willing to adjust the queue size, or users (like me) who have to use the queue in a complex "on-top-of-RTOS-but-the-timer-driver-calling-back-from-ISR" scenario can customize the mutex that protects the queue.

The one thing I'm not completely happy with is the need to call `{ embassy_time::queue::initialize() }` early on before any futures using embassy-time are polled, which is currently on the shoulders of the user. I'm open to any ideas where we can get rid of this and do it on the first call to `_embassy_time_schedule_wake`, without introducing very complex combinations of critical sections, atomics and whatnot.




Co-authored-by: ivmarkov <ivan.markov@gmail.com>
Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-10-26 19:14:12 +00:00
Dario Nieuwenhuis
f9da6271ce time/generic_queue: use Vec instead of SortedLinkedList 2022-10-26 21:00:50 +02:00
Dario Nieuwenhuis
4976cbbe60 time/generic-queue: ensure queue goes in .bss instead of .data 2022-10-26 20:02:58 +02:00
bors[bot]
9b86de770b
Merge #1031
1031: stm32: Add support for read_until_idle on UART - rebase r=Dirbaio a=Dirbaio

`@guillaume-michel` I rebased #1011 for you and then noticed you don't have the "allowed maintainers to push" option so I had to open a new PR. 

bors r+

Co-authored-by: Guillaume MICHEL <guillaume@squaremind.io>
2022-10-26 17:16:15 +00:00
Guillaume MICHEL
9cac649fcf stm32: Add support for read_until_idle on UART 2022-10-26 19:06:18 +02:00
Dario Nieuwenhuis
ff76fde299
Merge pull request #1030 from embassy-rs/update-nightly
Update Rust nightly.
2022-10-26 18:41:23 +02:00
ivmarkov
560eecdb73 Remove the _embassy_time_schedule_wake magic 2022-10-26 18:05:27 +03:00
ivmarkov
ac6995f9e6 Fix a bug identified during code review 2022-10-26 17:48:22 +03:00
Dario Nieuwenhuis
eeb072d9cb Update Rust nightly. 2022-10-26 16:47:29 +02:00
bors[bot]
1b249ca72d
Merge #987
987: (embassy-stm32): uart flowcontrol r=Dirbaio a=MathiasKoch

Add RTS & CTS flow control to stm32 UARTs

Co-authored-by: Mathias <mk@blackbird.online>
2022-10-26 10:18:44 +00:00
Mathias
66611a80ca Introduce shared new_inner for uart instantiation 2022-10-26 11:51:37 +02:00
Mathias
d1eee52625 Merge branch 'master' of https://github.com/embassy-rs/embassy into embassy-stm32/uart-flowcontrol 2022-10-26 11:47:00 +02:00
bors[bot]
71cc6833e1
Merge #1029
1029: Update nrf pacs r=Dirbaio a=diondokter



Co-authored-by: Dion Dokter <dion@tweedegolf.com>
2022-10-26 09:35:44 +00:00
Dion Dokter
0c9ec8dc36 Update usb 2022-10-26 10:39:29 +02:00
Dion Dokter
ea868920e6 Update nrf pacs 2022-10-26 09:13:26 +02:00
chemicstry
52c03cf0a4 Add more docs 2022-10-24 22:48:40 +03:00
chemicstry
ac61e0ee9f fmt 2022-10-24 22:39:13 +03:00
chemicstry
33f75419e5 Unify i2cv1 definition with i2cv2 2022-10-24 22:34:10 +03:00
chemicstry
6062978d58 Remove weird async timeouts 2022-10-24 22:22:20 +03:00
chemicstry
ca8afacfd0 Implement TimeoutI2c for i2cv2 2022-10-24 22:11:15 +03:00
chemicstry
9ad7e85288 Merge branch 'i2c_timeout2_v2' into i2c_timeout2 2022-10-24 21:50:29 +03:00
chemicstry
9b209ffe1c Add docs 2022-10-24 12:39:47 +03:00
chemicstry
5f02bee388 Gate TimeoutI2c behind i2cv1 2022-10-24 12:34:55 +03:00
chemicstry
1bed02296c i2cv2 timeouts 2022-10-24 12:33:17 +03:00
ivmarkov
516f4ce946 Fix embassy-time wasm build and fix a bug in wasm time driver 2022-10-24 12:15:53 +03:00
chemicstry
d99841fea9 Implement time feature 2022-10-24 11:38:15 +03:00
ivmarkov
e3cf4255c6 Help compiler with type inference 2022-10-24 11:31:54 +03:00
chemicstry
4ce4131f8b Implement i2cv1 timeout 2022-10-24 11:30:04 +03:00
ivmarkov
f78c706b89 Address review feedback 2022-10-24 11:10:59 +03:00
ivmarkov
4d5550070f Change time Driver contract to never fire the alarm synchronously 2022-10-24 09:17:43 +03:00
ivmarkov
53608a87ac Address feedback after code review 2022-10-24 08:21:35 +03:00
ivmarkov
ba6e452cc5 Documentation and initial testing framework
Add mock waker

First simple test

Tests & documentation
2022-10-24 08:21:31 +03:00
ivmarkov
c2404ee8ca Initial generic timer queue impl 2022-10-24 08:20:29 +03:00
bors[bot]
ce1cba761c
Merge #855
855: PDM microphone support for nrf r=Dirbaio a=pbert519

PDM microphones have a long startup phase, therefore the driver samples continuously and only switches the target buffer if the user requests sampling.

Co-authored-by: pbert <pbert@posteo.net>
2022-10-21 21:03:51 +00:00
bors[bot]
495ca6108c
Merge #1020
1020: Fix mistaken EP_IN_WAKERS r=Dirbaio a=mkj

I'm not totally certain, but this looks like a typo?

Co-authored-by: Matt Johnston <matt@ucc.asn.au>
2022-10-21 20:43:14 +00:00
bors[bot]
73d06dd67b
Merge #1021
1021: rp usb: wait for accept() completion r=Dirbaio a=mkj

This fixes failures when `defmt` feature isn't enabled (timing related). 

Co-authored-by: Matt Johnston <matt@ucc.asn.au>
2022-10-21 19:48:49 +00:00
Matt Johnston
866a42f3ae rp usb: wait for accept() completion
This ensures that the current response has finished being sent
before the subsequent set_address() happens. Otherwise connecting
a device is intermittent, can fail depending on timing.
2022-10-21 22:02:13 +08:00
Matt Johnston
f45d34ce7c Fix mistaken EP_IN_WAKERS 2022-10-20 23:46:02 +08:00
bors[bot]
bf0ad38640
Merge #1019
1019: Add missing files and features for basic example r=lulf a=lulf



Co-authored-by: Ulf Lilleengen <ulf.lilleengen@gmail.com>
2022-10-20 14:18:47 +00:00
Ulf Lilleengen
de103a5f4f Add missing files and features for basic example 2022-10-20 16:12:59 +02:00
bors[bot]
8c42b26fc6
Merge #1017
1017: Add missing examples to rust-analyzer linked projects r=lulf a=GrantM11235



Co-authored-by: Grant Miller <GrantM11235@gmail.com>
2022-10-19 10:37:22 +00:00
Grant Miller
fa495b8e88 Add missing examples to rust-analyzer linked projects 2022-10-19 03:39:29 -05:00
bors[bot]
d9c773f475
Merge #1014
1014: Add memory barriers to H7 flash driver to mitigate PGSERR errors r=lulf a=matoushybl

The stm32h7xx-hal uses only the ordering barrier, while the CubeMX uses the DSB and ISB instructions, to be on the safe side, both are used here.

Without the barrier, the PG bit is not set, when the writes are being done, resulting in an error.

Co-authored-by: Matous Hybl <hyblmatous@gmail.com>
2022-10-19 07:29:12 +00:00
bors[bot]
a669f4cfd8
Merge #1015
1015: Enable defmt in embassy-hal-common when defmt is enabled in stm32 HAL r=Dirbaio a=matoushybl



Co-authored-by: Matous Hybl <hyblmatous@gmail.com>
2022-10-18 21:12:05 +00:00
Matous Hybl
9d2641f2f5 Enable defmt in embassy-hal-common 2022-10-18 22:48:43 +02:00
Matous Hybl
6c5d81ada5 Add memory barriers to H7 flash driver to mitigate PGSERR errors
The stm32h7xx-hal uses only the ordering barrier, while the CubeMX uses the DSB and ISB instructions, to be on the safe side, both are used here.
2022-10-18 22:42:02 +02:00
bors[bot]
18453ee64c
Merge #1012
1012: rp i2c: have separate wakers for each i2c unit r=Dirbaio a=jsgf

If they both share one waker, there's the possibility that some wakeups could get lost.

Co-authored-by: Jeremy Fitzhardinge <jeremy@goop.org>
2022-10-18 08:29:43 +00:00
Jeremy Fitzhardinge
02a3cdb507 Associate state with the instance rather than having a separate array 2022-10-17 21:50:40 -07:00
Jeremy Fitzhardinge
e4c2b2aa9a rp i2c: have separate wakers for each i2c unit
If they both share one waker, there's the possibility that some wakeups
could get lost.
2022-10-16 18:00:23 -07:00