Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use wfi in otherwise empty infinite loops in examples #408

Merged
merged 1 commit into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion boards/rp-pico/examples/pico_i2c_pio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ fn main() -> ! {
print_temperature(&mut uart, temp);

loop {
cortex_m::asm::nop();
cortex_m::asm::wfi();
}
}

Expand Down
3 changes: 1 addition & 2 deletions rp2040-hal/examples/dht11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,8 @@ fn main() -> ! {
// In this case, we just ignore the result. A real application
// would do something with the measurement.

#[allow(clippy::empty_loop)]
loop {
// Empty loop
cortex_m::asm::wfi();
}
}

Expand Down
6 changes: 1 addition & 5 deletions rp2040-hal/examples/gpio_irq_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,7 @@ fn main() -> ! {

loop {
// interrupts handle everything else in this example.
// if we wanted low power we could go to sleep. to
// 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();
cortex_m::asm::wfi();
}
}

Expand Down
3 changes: 1 addition & 2 deletions rp2040-hal/examples/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ fn main() -> ! {

// Demo finish - just loop until reset

#[allow(clippy::empty_loop)]
loop {
// Empty loop
cortex_m::asm::wfi();
}
}

Expand Down
3 changes: 1 addition & 2 deletions rp2040-hal/examples/lcd_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ fn main() -> ! {
lcd.write_str("HD44780!", &mut delay).unwrap();

// Do nothing - we're finished
#[allow(clippy::empty_loop)]
loop {
// Empty loop
cortex_m::asm::wfi();
}
}

Expand Down
5 changes: 3 additions & 2 deletions rp2040-hal/examples/pio_blink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ fn main() -> ! {
sm.start();

// PIO runs in background, independently from CPU
#[allow(clippy::empty_loop)]
loop {}
loop {
cortex_m::asm::wfi();
}
}
5 changes: 3 additions & 2 deletions rp2040-hal/examples/pio_proc_blink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ fn main() -> ! {
sm.start();

// PIO runs in background, independently from CPU
#[allow(clippy::empty_loop)]
loop {}
loop {
cortex_m::asm::wfi();
}
}
5 changes: 3 additions & 2 deletions rp2040-hal/examples/pio_side_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ fn main() -> ! {
sm.start();

// PIO runs in background, independently from CPU
#[allow(clippy::empty_loop)]
loop {}
loop {
cortex_m::asm::wfi();
}
}
5 changes: 3 additions & 2 deletions rp2040-hal/examples/pio_synchronized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ fn main() -> ! {
cortex_m::asm::delay(10_000_000);
let _sm2 = sm2.stop();

#[allow(clippy::empty_loop)]
loop {}
loop {
cortex_m::asm::wfi();
}
}
2 changes: 1 addition & 1 deletion rp2040-hal/examples/rom_funcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ fn main() -> ! {

// In case the reboot fails
loop {
cortex_m::asm::nop();
cortex_m::asm::wfi();
}
}

Expand Down
3 changes: 1 addition & 2 deletions rp2040-hal/examples/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,8 @@ fn main() -> ! {
Err(_) => {} // handle errors
};

#[allow(clippy::empty_loop)]
loop {
// Empty loop
cortex_m::asm::wfi();
}
}

Expand Down