Skip to content

Commit

Permalink
tcl: add get_bit & get_bitfield memory helper functions
Browse files Browse the repository at this point in the history
Signed-off-by: Erhan Kurubas <[email protected]>
Change-Id: I21506526e3ebd9c3a70a25ba60bf83aee431feb6
Reviewed-on: https://review.openocd.org/c/openocd/+/7016
Tested-by: jenkins
Reviewed-by: Antonio Borneo <[email protected]>
  • Loading branch information
erhankur authored and borneoa committed Jun 10, 2022
1 parent d1b882f commit 7033850
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tcl/mmr_helpers.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,22 @@ proc show_mmr_bitfield { MSB LSB VAL FIELDNAME FIELDVALUES } {
}
echo [format "%-15s: %d (0x%0*x) %s" $FIELDNAME $nval $width $nval $sval ]
}

# Give: ADDR - address of the register.
# BIT - bit's number.

proc get_mmr_bit { ADDR BIT } {
set val [memread32 $ADDR]
set bit_val [expr {$val & [expr {1 << $BIT}]}]
return $bit_val
}


# Give: ADDR - address of the register.
# MSB - MSB bit's number.
# LSB - LSB bit's number.

proc get_mmr_bitfield { ADDR MSB LSB } {
set rval [memread32 $ADDR]
return normalize_bitfield $rval $MSB $LSB
}

0 comments on commit 7033850

Please sign in to comment.