diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-07-29 21:58:35 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-07-29 23:40:36 +0200 |
| commit | a0f1b0ee01d461607660d2d56b5b1bdc57e0d3fb (patch) | |
| tree | e60fc8f8db8ec07e55d655c1a830b07f4db0b7d2 /embassy-nrf/src/buffered_uarte.rs | |
| parent | 8745d646f0976791b7098456aa61adb983fb1c18 (diff) | |
Split embassy crate into embassy-executor, embassy-util.
Diffstat (limited to 'embassy-nrf/src/buffered_uarte.rs')
| -rw-r--r-- | embassy-nrf/src/buffered_uarte.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/embassy-nrf/src/buffered_uarte.rs b/embassy-nrf/src/buffered_uarte.rs index 89c1ba908..21ff1d73b 100644 --- a/embassy-nrf/src/buffered_uarte.rs +++ b/embassy-nrf/src/buffered_uarte.rs | |||
| @@ -18,10 +18,10 @@ use core::future::Future; | |||
| 18 | use core::sync::atomic::{compiler_fence, Ordering}; | 18 | use core::sync::atomic::{compiler_fence, Ordering}; |
| 19 | use core::task::Poll; | 19 | use core::task::Poll; |
| 20 | 20 | ||
| 21 | use embassy::waitqueue::WakerRegistration; | ||
| 22 | use embassy_cortex_m::peripheral::{PeripheralMutex, PeripheralState, StateStorage}; | 21 | use embassy_cortex_m::peripheral::{PeripheralMutex, PeripheralState, StateStorage}; |
| 23 | use embassy_hal_common::ring_buffer::RingBuffer; | 22 | use embassy_hal_common::ring_buffer::RingBuffer; |
| 24 | use embassy_hal_common::{into_ref, low_power_wait_until, PeripheralRef}; | 23 | use embassy_hal_common::{into_ref, PeripheralRef}; |
| 24 | use embassy_util::waitqueue::WakerRegistration; | ||
| 25 | use futures::future::poll_fn; | 25 | use futures::future::poll_fn; |
| 26 | // Re-export SVD variants to allow user to directly set values | 26 | // Re-export SVD variants to allow user to directly set values |
| 27 | pub use pac::uarte0::{baudrate::BAUDRATE_A as Baudrate, config::PARITY_A as Parity}; | 27 | pub use pac::uarte0::{baudrate::BAUDRATE_A as Baudrate, config::PARITY_A as Parity}; |
| @@ -450,3 +450,13 @@ impl<'a, U: UarteInstance, T: TimerInstance> PeripheralState for StateInner<'a, | |||
| 450 | trace!("irq: end"); | 450 | trace!("irq: end"); |
| 451 | } | 451 | } |
| 452 | } | 452 | } |
| 453 | |||
| 454 | /// Low power blocking wait loop using WFE/SEV. | ||
| 455 | fn low_power_wait_until(mut condition: impl FnMut() -> bool) { | ||
| 456 | while !condition() { | ||
| 457 | // WFE might "eat" an event that would have otherwise woken the executor. | ||
| 458 | cortex_m::asm::wfe(); | ||
| 459 | } | ||
| 460 | // Retrigger an event to be transparent to the executor. | ||
| 461 | cortex_m::asm::sev(); | ||
| 462 | } | ||
