contrib/firmware: add 'send not acknowledged' function to the i2c bit-banging impleme...
[openocd.git] / tcl / mem_helper.tcl
blob0229d54b783ac606556a405bb0ef8acbd0481631
1 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Helper for common memory read/modify/write procedures
5 # mrw: "memory read word", returns value of $reg
6 proc mrw {reg} {
7 return [read_memory $reg 32 1]
10 add_usage_text mrw "address"
11 add_help_text mrw "Returns value of word in memory."
13 # mrh: "memory read halfword", returns value of $reg
14 proc mrh {reg} {
15 return [read_memory $reg 16 1]
18 add_usage_text mrh "address"
19 add_help_text mrh "Returns value of halfword in memory."
21 # mrb: "memory read byte", returns value of $reg
22 proc mrb {reg} {
23 return [read_memory $reg 8 1]
26 add_usage_text mrb "address"
27 add_help_text mrb "Returns value of byte in memory."
29 # mmw: "memory modify word", updates value of $reg
30 # $reg <== ((value & ~$clearbits) | $setbits)
31 proc mmw {reg setbits clearbits} {
32 set old [mrw $reg]
33 set new [expr {($old & ~$clearbits) | $setbits}]
34 mww $reg $new
37 add_usage_text mmw "address setbits clearbits"
38 add_help_text mmw "Modify word in memory. new_val = (old_val & ~clearbits) | setbits;"