diff options
author | Erhan Kurubas <erhan.kurubas@espressif.com> | 2022-06-04 00:25:19 +0200 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2022-06-10 21:56:20 +0000 |
commit | 70338509ca52a9b78c52a5d464ba2605fbaf193b (patch) | |
tree | e241f64d061fe81a5ef56d633988f740f20a1fb3 /tcl | |
parent | d1b882f2c014258be5397067e45848fa5465b78b (diff) | |
download | riscv-openocd-70338509ca52a9b78c52a5d464ba2605fbaf193b.zip riscv-openocd-70338509ca52a9b78c52a5d464ba2605fbaf193b.tar.gz riscv-openocd-70338509ca52a9b78c52a5d464ba2605fbaf193b.tar.bz2 |
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>
Diffstat (limited to 'tcl')
-rw-r--r-- | tcl/mmr_helpers.tcl | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tcl/mmr_helpers.tcl b/tcl/mmr_helpers.tcl index d9b6e63..61c58e7 100644 --- a/tcl/mmr_helpers.tcl +++ b/tcl/mmr_helpers.tcl @@ -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 +} |