From 0ddbe7da80e9ab44a76b3f18bc61d963483e6ab3 Mon Sep 17 00:00:00 2001 From: Matt Mets Date: Sat, 30 Nov 2024 20:44:30 +0100 Subject: [PATCH] Use CMSYS registers for resetw --- src/machine/machine_rp2040_resets.go | 15 ++++----------- src/machine/machine_rp2350_resets.go | 15 ++++----------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/src/machine/machine_rp2040_resets.go b/src/machine/machine_rp2040_resets.go index 6f15e99528..bf974e9785 100644 --- a/src/machine/machine_rp2040_resets.go +++ b/src/machine/machine_rp2040_resets.go @@ -4,7 +4,6 @@ package machine import ( "device/rp" - "runtime/volatile" "unsafe" ) @@ -13,24 +12,18 @@ import ( // TODO: This field is not available in the device file. const RESETS_RESET_Msk = 0x01ffffff -type resetsType struct { - reset volatile.Register32 - wdSel volatile.Register32 - resetDone volatile.Register32 -} - -var resets = (*resetsType)(unsafe.Pointer(rp.RESETS)) +var resets = (*rp.RESETS_Type)(unsafe.Pointer(rp.RESETS)) // resetBlock resets hardware blocks specified // by the bit pattern in bits. func resetBlock(bits uint32) { - resets.reset.SetBits(bits) + resets.RESET.SetBits(bits) } // unresetBlock brings hardware blocks specified by the // bit pattern in bits out of reset. func unresetBlock(bits uint32) { - resets.reset.ClearBits(bits) + resets.RESET.ClearBits(bits) } // unresetBlockWait brings specified hardware blocks @@ -38,6 +31,6 @@ func unresetBlock(bits uint32) { // out of reset and wait for completion. func unresetBlockWait(bits uint32) { unresetBlock(bits) - for !resets.resetDone.HasBits(bits) { + for !resets.RESET_DONE.HasBits(bits) { } } diff --git a/src/machine/machine_rp2350_resets.go b/src/machine/machine_rp2350_resets.go index 596912741a..1cd70b424e 100644 --- a/src/machine/machine_rp2350_resets.go +++ b/src/machine/machine_rp2350_resets.go @@ -4,7 +4,6 @@ package machine import ( "device/rp" - "runtime/volatile" "unsafe" ) @@ -13,24 +12,18 @@ import ( // TODO: This field is not available in the device file. const RESETS_RESET_Msk = 0x1fffffff -type resetsType struct { - reset volatile.Register32 - wdSel volatile.Register32 - resetDone volatile.Register32 -} - -var resets = (*resetsType)(unsafe.Pointer(rp.RESETS)) +var resets = (*rp.RESETS_Type)(unsafe.Pointer(rp.RESETS)) // resetBlock resets hardware blocks specified // by the bit pattern in bits. func resetBlock(bits uint32) { - resets.reset.SetBits(bits) + resets.RESET.SetBits(bits) } // unresetBlock brings hardware blocks specified by the // bit pattern in bits out of reset. func unresetBlock(bits uint32) { - resets.reset.ClearBits(bits) + resets.RESET.ClearBits(bits) } // unresetBlockWait brings specified hardware blocks @@ -38,6 +31,6 @@ func unresetBlock(bits uint32) { // out of reset and wait for completion. func unresetBlockWait(bits uint32) { unresetBlock(bits) - for !resets.resetDone.HasBits(bits) { + for !resets.RESET_DONE.HasBits(bits) { } }