429: nrf/uarte: do not use WFE on drop. r=Dirbaio a=Dirbaio

- It disturbs other stuff that uses WFE/SEV in the system. I ran into issues with this.
- It needs the irq handler to check for RXTO/TXSTOPPED errors, which makes it slower.

431: interrupt: transmute instead of steal. r=Dirbaio a=Dirbaio

That steal method has a TAKEN=true write [here](6b013138b7/src/peripheral/mod.rs (L180)).
This is not zero cost, we don't want it. Transmute instead, which is zero cost.

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
This commit is contained in:
bors[bot] 2021-10-16 14:21:36 +00:00 committed by GitHub
commit d81a203ee2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 19 deletions

View file

@ -187,13 +187,6 @@ impl<'d, T: Instance> Uarte<'d, T> {
s.endtx_waker.wake();
r.intenclr.write(|w| w.endtx().clear());
}
if r.events_rxto.read().bits() != 0 {
r.intenclr.write(|w| w.rxto().clear());
}
if r.events_txstopped.read().bits() != 0 {
r.intenclr.write(|w| w.txstopped().clear());
}
}
}
@ -208,15 +201,9 @@ impl<'a, T: Instance> Drop for Uarte<'a, T> {
info!("did_stoprx {} did_stoptx {}", did_stoprx, did_stoptx);
// Wait for rxto or txstopped, if needed.
r.intenset.write(|w| w.rxto().set().txstopped().set());
while (did_stoprx && r.events_rxto.read().bits() == 0)
|| (did_stoptx && r.events_txstopped.read().bits() == 0)
{
info!("uarte drop: wfe");
cortex_m::asm::wfe();
}
cortex_m::asm::sev();
{}
// Finally we can disable!
r.enable.write(|w| w.enable().disabled());

View file

@ -1,8 +1,8 @@
use atomic_polyfill::{compiler_fence, AtomicPtr, Ordering};
use core::mem;
use core::ptr;
use cortex_m::peripheral::NVIC;
use atomic_polyfill::{compiler_fence, AtomicPtr, Ordering};
pub use embassy_macros::interrupt_declare as declare;
pub use embassy_macros::interrupt_take as take;
@ -124,9 +124,8 @@ impl<T: Interrupt + ?Sized> InterruptExt for T {
#[inline]
fn set_priority(&self, prio: Self::Priority) {
unsafe {
cortex_m::peripheral::Peripherals::steal()
.NVIC
.set_priority(NrWrap(self.number()), prio.into())
let mut nvic: cortex_m::peripheral::NVIC = mem::transmute(());
nvic.set_priority(NrWrap(self.number()), prio.into())
}
}
}