aboutsummaryrefslogtreecommitdiff
path: root/embassy-nrf/src
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-nrf/src')
-rw-r--r--embassy-nrf/src/buffered_uarte.rs28
-rw-r--r--embassy-nrf/src/timer.rs2
-rw-r--r--embassy-nrf/src/uarte.rs2
3 files changed, 17 insertions, 15 deletions
diff --git a/embassy-nrf/src/buffered_uarte.rs b/embassy-nrf/src/buffered_uarte.rs
index a5a37b982..9be4d4d54 100644
--- a/embassy-nrf/src/buffered_uarte.rs
+++ b/embassy-nrf/src/buffered_uarte.rs
@@ -175,8 +175,8 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> {
175 175
176 pub fn set_baudrate(self: Pin<&mut Self>, baudrate: Baudrate) { 176 pub fn set_baudrate(self: Pin<&mut Self>, baudrate: Baudrate) {
177 let mut inner = self.inner(); 177 let mut inner = self.inner();
178 inner.as_mut().register_interrupt(); 178 unsafe { inner.as_mut().register_interrupt_unchecked() }
179 inner.with(|state, _irq| { 179 inner.with(|state| {
180 let r = U::regs(); 180 let r = U::regs();
181 181
182 let timeout = 0x8000_0000 / (baudrate as u32 / 40); 182 let timeout = 0x8000_0000 / (baudrate as u32 / 40);
@@ -195,8 +195,8 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> {
195impl<'d, U: UarteInstance, T: TimerInstance> AsyncBufRead for BufferedUarte<'d, U, T> { 195impl<'d, U: UarteInstance, T: TimerInstance> AsyncBufRead for BufferedUarte<'d, U, T> {
196 fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<&[u8]>> { 196 fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<&[u8]>> {
197 let mut inner = self.inner(); 197 let mut inner = self.inner();
198 inner.as_mut().register_interrupt(); 198 unsafe { inner.as_mut().register_interrupt_unchecked() }
199 inner.with(|state, _irq| { 199 inner.with(|state| {
200 // Conservative compiler fence to prevent optimizations that do not 200 // Conservative compiler fence to prevent optimizations that do not
201 // take in to account actions by DMA. The fence has been placed here, 201 // take in to account actions by DMA. The fence has been placed here,
202 // before any DMA action has started 202 // before any DMA action has started
@@ -220,20 +220,20 @@ impl<'d, U: UarteInstance, T: TimerInstance> AsyncBufRead for BufferedUarte<'d,
220 220
221 fn consume(self: Pin<&mut Self>, amt: usize) { 221 fn consume(self: Pin<&mut Self>, amt: usize) {
222 let mut inner = self.inner(); 222 let mut inner = self.inner();
223 inner.as_mut().register_interrupt(); 223 unsafe { inner.as_mut().register_interrupt_unchecked() }
224 inner.with(|state, irq| { 224 inner.as_mut().with(|state| {
225 trace!("consume {:?}", amt); 225 trace!("consume {:?}", amt);
226 state.rx.pop(amt); 226 state.rx.pop(amt);
227 irq.pend(); 227 });
228 }) 228 inner.pend();
229 } 229 }
230} 230}
231 231
232impl<'d, U: UarteInstance, T: TimerInstance> AsyncWrite for BufferedUarte<'d, U, T> { 232impl<'d, U: UarteInstance, T: TimerInstance> AsyncWrite for BufferedUarte<'d, U, T> {
233 fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize>> { 233 fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize>> {
234 let mut inner = self.inner(); 234 let mut inner = self.inner();
235 inner.as_mut().register_interrupt(); 235 unsafe { inner.as_mut().register_interrupt_unchecked() }
236 inner.with(|state, irq| { 236 let poll = inner.as_mut().with(|state| {
237 trace!("poll_write: {:?}", buf.len()); 237 trace!("poll_write: {:?}", buf.len());
238 238
239 let tx_buf = state.tx.push_buf(); 239 let tx_buf = state.tx.push_buf();
@@ -254,10 +254,12 @@ impl<'d, U: UarteInstance, T: TimerInstance> AsyncWrite for BufferedUarte<'d, U,
254 // before any DMA action has started 254 // before any DMA action has started
255 compiler_fence(Ordering::SeqCst); 255 compiler_fence(Ordering::SeqCst);
256 256
257 irq.pend();
258
259 Poll::Ready(Ok(n)) 257 Poll::Ready(Ok(n))
260 }) 258 });
259
260 inner.pend();
261
262 poll
261 } 263 }
262} 264}
263 265
diff --git a/embassy-nrf/src/timer.rs b/embassy-nrf/src/timer.rs
index a6e91f228..7ff35c320 100644
--- a/embassy-nrf/src/timer.rs
+++ b/embassy-nrf/src/timer.rs
@@ -29,7 +29,7 @@ pub(crate) mod sealed {
29 pub trait ExtendedInstance {} 29 pub trait ExtendedInstance {}
30} 30}
31 31
32pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static { 32pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static + Send {
33 type Interrupt: Interrupt; 33 type Interrupt: Interrupt;
34} 34}
35pub trait ExtendedInstance: Instance + sealed::ExtendedInstance {} 35pub trait ExtendedInstance: Instance + sealed::ExtendedInstance {}
diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs
index 67ec5d73f..985854a5f 100644
--- a/embassy-nrf/src/uarte.rs
+++ b/embassy-nrf/src/uarte.rs
@@ -461,7 +461,7 @@ pub(crate) mod sealed {
461 } 461 }
462} 462}
463 463
464pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static { 464pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static + Send {
465 type Interrupt: Interrupt; 465 type Interrupt: Interrupt;
466} 466}
467 467