Skip to content

Commit

Permalink
Use CMSYS registers for resetw
Browse files Browse the repository at this point in the history
  • Loading branch information
cibomahto committed Nov 30, 2024
1 parent 96bb225 commit 0ddbe7d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
15 changes: 4 additions & 11 deletions src/machine/machine_rp2040_resets.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package machine

import (
"device/rp"
"runtime/volatile"
"unsafe"
)

Expand All @@ -13,31 +12,25 @@ 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
// specified by the bit pattern in bits
// out of reset and wait for completion.
func unresetBlockWait(bits uint32) {
unresetBlock(bits)
for !resets.resetDone.HasBits(bits) {
for !resets.RESET_DONE.HasBits(bits) {
}
}
15 changes: 4 additions & 11 deletions src/machine/machine_rp2350_resets.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package machine

import (
"device/rp"
"runtime/volatile"
"unsafe"
)

Expand All @@ -13,31 +12,25 @@ 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
// specified by the bit pattern in bits
// out of reset and wait for completion.
func unresetBlockWait(bits uint32) {
unresetBlock(bits)
for !resets.resetDone.HasBits(bits) {
for !resets.RESET_DONE.HasBits(bits) {
}
}

0 comments on commit 0ddbe7d

Please sign in to comment.