tcl: add get_bit & get_bitfield memory helper functions
Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com> Change-Id: I21506526e3ebd9c3a70a25ba60bf83aee431feb6 Reviewed-on: https://review.openocd.org/c/openocd/+/7016 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
parent
d1b882f2c0
commit
70338509ca
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue