Skip to content

Commit 0595f11

Browse files
kalkyljamesmunns
authored andcommitted
Acquire semaphore in transfer wait
1 parent 79b1ee2 commit 0595f11

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

examples/spis-demo/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ const APP: () = {
6161
ctx.resources.gpiote.reset_events();
6262
rprintln!("Reset buffer");
6363
let (buf, spis) = ctx.resources.transfer.take().unwrap().wait();
64-
spis.acquire(); // Acquire the SPIS semaphore to be able to safely update `buf`
6564
buf.copy_from_slice(&[0; 8][..]);
6665
rprintln!("{:?}", buf);
6766
*ctx.resources.transfer = spis.transfer(buf).ok();

nrf-hal-common/src/spis.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ impl<T: Instance, B> Transfer<T, B> {
470470
.take()
471471
.unwrap_or_else(|| unsafe { core::hint::unreachable_unchecked() });
472472
while !inner.spis.is_done() {}
473+
inner.spis.acquire();
473474
compiler_fence(Ordering::Acquire);
474475
(inner.buffer, inner.spis)
475476
}
@@ -513,6 +514,7 @@ impl<T: Instance, TxB, RxB> TransferSplit<T, TxB, RxB> {
513514
.take()
514515
.unwrap_or_else(|| unsafe { core::hint::unreachable_unchecked() });
515516
while !inner.spis.is_done() {}
517+
inner.spis.acquire();
516518
compiler_fence(Ordering::Acquire);
517519
(inner.tx_buffer, inner.rx_buffer, inner.spis)
518520
}

0 commit comments

Comments
 (0)