A mutex implementation based on the rp2040 hardware spinlock.
Fully working code can be found in examples/
.
use rp_spinlockmutex::SpinlockMutex;
static MUTEX: SpinlockMutex<7, i32> = SpinlockMutex::new(0);
run_on_core1(|| {
for _ in 0..10 {
*MUTEX.lock() += 1;
}
});
for _ in 0..10 {
*MUTEX.lock() += 1;
}
assert_eq!(*mutex.lock(), 20);
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/license/mit/)
at your option.