Skip to content

Commit

Permalink
Do a full reset, even though it breaks an open debug connection
Browse files Browse the repository at this point in the history
  • Loading branch information
jannic committed Jul 22, 2023
1 parent dc21587 commit a642b71
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions rp2040-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,12 @@ pub use watchdog::Watchdog;

/// Trigger full reset of the RP2040.
///
/// When called from core0, it will shut down core1 and
/// then call `SCB::sys_reset()`, which keeps the debug
/// connection active.
///
/// This is not possible when called from core1. It will
/// trigger a watchdog reset of the whole system instead,
/// which breaks a running debug connection.
/// Uses the watchdog and the power-on state machine (PSM) to reset all on-chip components.
pub fn reset() -> ! {
unsafe {
if crate::Sio::core() == CoreId::Core0 {
(*pac::PSM::PTR).frce_off.write(|w| w.proc1().set_bit());
pac::SCB::sys_reset();
} else {
(*pac::PSM::PTR).wdsel.write(|w| w.bits(0x0000ffff));
(*pac::WATCHDOG::PTR).ctrl.write(|w| w.trigger().set_bit());
}
cortex_m::interrupt::disable();
(*pac::PSM::PTR).wdsel.write(|w| w.bits(0x0001ffff));
(*pac::WATCHDOG::PTR).ctrl.write(|w| w.trigger().set_bit());
#[allow(clippy::empty_loop)]
loop {}
}
Expand All @@ -125,7 +115,7 @@ pub fn reset() -> ! {
/// Completely disables the other core, and parks the current core in an
/// infinite loop with interrupts disabled.
///
/// Doesn't stop other subsystems.
/// Doesn't stop other subsystems, like the DMA controller.
pub fn halt() -> ! {
unsafe {
cortex_m::interrupt::disable();
Expand Down

0 comments on commit a642b71

Please sign in to comment.