embassy/embassy-rp/src/reset.rs

16 lines
454 B
Rust
Raw Normal View History

2021-06-25 03:38:03 +02:00
pub use pac::resets::regs::Peripherals;
2022-06-12 22:15:44 +02:00
use crate::pac;
2021-06-25 03:38:03 +02:00
pub const ALL_PERIPHERALS: Peripherals = Peripherals(0x01ffffff);
2023-06-16 01:32:18 +02:00
pub(crate) fn reset(peris: Peripherals) {
2021-06-25 03:38:03 +02:00
pac::RESETS.reset().write_value(peris);
}
2023-06-16 01:32:18 +02:00
pub(crate) fn unreset_wait(peris: Peripherals) {
2021-06-25 03:38:03 +02:00
// TODO use the "atomic clear" register version
2022-06-12 22:15:44 +02:00
pac::RESETS.reset().modify(|v| *v = Peripherals(v.0 & !peris.0));
2021-06-25 03:38:03 +02:00
while ((!pac::RESETS.reset_done().read().0) & peris.0) != 0 {}
}