mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2025-01-10 04:21:32 +11:00
Use wfi in otherwise empty infinite loops in examples
- Clippy warns about empty loops, https://github.com/rust-lang/rust-clippy/issues/6161 - wfi allows to CPU to save some power WFI was avoided in examples for fear of ill interactions with debuggers. However the rp2040 debug port does continue to work, as long as the relevant clocks are not disabled in SLEEP_EN0/SLEEP_EN1. (By default, all clocks stay enabled in sleep mode.) This patch replaces several different workarounds with just calling wfi.
This commit is contained in:
parent
6dafcc1ac0
commit
44019781e2
|
@ -149,7 +149,7 @@ fn main() -> ! {
|
||||||
print_temperature(&mut uart, temp);
|
print_temperature(&mut uart, temp);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
cortex_m::asm::nop();
|
cortex_m::asm::wfi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,9 +139,8 @@ fn main() -> ! {
|
||||||
// In this case, we just ignore the result. A real application
|
// In this case, we just ignore the result. A real application
|
||||||
// would do something with the measurement.
|
// would do something with the measurement.
|
||||||
|
|
||||||
#[allow(clippy::empty_loop)]
|
|
||||||
loop {
|
loop {
|
||||||
// Empty loop
|
cortex_m::asm::wfi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,11 +147,7 @@ fn main() -> ! {
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
// interrupts handle everything else in this example.
|
// interrupts handle everything else in this example.
|
||||||
// if we wanted low power we could go to sleep. to
|
cortex_m::asm::wfi();
|
||||||
// keep this example simple we'll just execute a `nop`.
|
|
||||||
// the `nop` (No Operation) instruction does nothing,
|
|
||||||
// but if we have no code here clippy would complain.
|
|
||||||
cortex_m::asm::nop();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,9 +97,8 @@ fn main() -> ! {
|
||||||
|
|
||||||
// Demo finish - just loop until reset
|
// Demo finish - just loop until reset
|
||||||
|
|
||||||
#[allow(clippy::empty_loop)]
|
|
||||||
loop {
|
loop {
|
||||||
// Empty loop
|
cortex_m::asm::wfi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,9 +113,8 @@ fn main() -> ! {
|
||||||
lcd.write_str("HD44780!", &mut delay).unwrap();
|
lcd.write_str("HD44780!", &mut delay).unwrap();
|
||||||
|
|
||||||
// Do nothing - we're finished
|
// Do nothing - we're finished
|
||||||
#[allow(clippy::empty_loop)]
|
|
||||||
loop {
|
loop {
|
||||||
// Empty loop
|
cortex_m::asm::wfi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,7 @@ fn main() -> ! {
|
||||||
sm.start();
|
sm.start();
|
||||||
|
|
||||||
// PIO runs in background, independently from CPU
|
// PIO runs in background, independently from CPU
|
||||||
#[allow(clippy::empty_loop)]
|
loop {
|
||||||
loop {}
|
cortex_m::asm::wfi();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@ fn main() -> ! {
|
||||||
sm.start();
|
sm.start();
|
||||||
|
|
||||||
// PIO runs in background, independently from CPU
|
// PIO runs in background, independently from CPU
|
||||||
#[allow(clippy::empty_loop)]
|
loop {
|
||||||
loop {}
|
cortex_m::asm::wfi();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ fn main() -> ! {
|
||||||
sm.start();
|
sm.start();
|
||||||
|
|
||||||
// PIO runs in background, independently from CPU
|
// PIO runs in background, independently from CPU
|
||||||
#[allow(clippy::empty_loop)]
|
loop {
|
||||||
loop {}
|
cortex_m::asm::wfi();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,7 @@ fn main() -> ! {
|
||||||
cortex_m::asm::delay(10_000_000);
|
cortex_m::asm::delay(10_000_000);
|
||||||
let _sm2 = sm2.stop();
|
let _sm2 = sm2.stop();
|
||||||
|
|
||||||
#[allow(clippy::empty_loop)]
|
loop {
|
||||||
loop {}
|
cortex_m::asm::wfi();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ fn main() -> ! {
|
||||||
|
|
||||||
// In case the reboot fails
|
// In case the reboot fails
|
||||||
loop {
|
loop {
|
||||||
cortex_m::asm::nop();
|
cortex_m::asm::wfi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,9 +121,8 @@ fn main() -> ! {
|
||||||
Err(_) => {} // handle errors
|
Err(_) => {} // handle errors
|
||||||
};
|
};
|
||||||
|
|
||||||
#[allow(clippy::empty_loop)]
|
|
||||||
loop {
|
loop {
|
||||||
// Empty loop
|
cortex_m::asm::wfi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue