doc: use the new jimtcl syntax for 'expr'
With jimtcl 0.81 the syntax of the TCL command 'expr' requires the multiple arguments to be within curly brackets. Update the examples in the documentation to follow the new syntax. While there, split one example to avoid it to exceed the line size during pdf document generation. Change-Id: I91cca419f8273415ccb0c2ce369fc6ac476e34e5 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6809 Tested-by: jenkins
This commit is contained in:
parent
aad8718058
commit
5a8d32fcb9
|
@ -174,7 +174,7 @@ them. It is similar to this bash statement.
|
||||||
EXPORT vn=`date`
|
EXPORT vn=`date`
|
||||||
|
|
||||||
LINE 2 & 3
|
LINE 2 & 3
|
||||||
set $vn [expr (1024 * $x)]
|
set $vn [expr {1024 * $x}]
|
||||||
global $vn
|
global $vn
|
||||||
|
|
||||||
In line 1, we dynamically created a variable name. Here, we are
|
In line 1, we dynamically created a variable name. Here, we are
|
||||||
|
|
|
@ -2009,9 +2009,9 @@ proc setc15 @{regs value@} @{
|
||||||
|
|
||||||
echo [format "set p15 0x%04x, 0x%08x" $regs $value]
|
echo [format "set p15 0x%04x, 0x%08x" $regs $value]
|
||||||
|
|
||||||
arm mcr 15 [expr ($regs>>12)&0x7] \
|
arm mcr 15 [expr @{($regs >> 12) & 0x7@}] \
|
||||||
[expr ($regs>>0)&0xf] [expr ($regs>>4)&0xf] \
|
[expr @{($regs >> 0) & 0xf@}] [expr @{($regs >> 4) & 0xf@}] \
|
||||||
[expr ($regs>>8)&0x7] $value
|
[expr @{($regs >> 8) & 0x7@}] $value
|
||||||
@}
|
@}
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
|
@ -3157,7 +3157,9 @@ the target's supply voltage.
|
||||||
The result can be converted to Volts (ignoring the most significant bytes, always zero)
|
The result can be converted to Volts (ignoring the most significant bytes, always zero)
|
||||||
@example
|
@example
|
||||||
> set a [st-link cmd 8 0xf7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
|
> set a [st-link cmd 8 0xf7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
|
||||||
> echo [expr 2*1.2*([lindex $a 4]+256*[lindex $a 5])/([lindex $a 0]+256*[lindex $a 1])]
|
> set n [expr @{[lindex $a 4] + 256 * [lindex $a 5]@}]
|
||||||
|
> set d [expr @{[lindex $a 0] + 256 * [lindex $a 1]@}]
|
||||||
|
> echo [expr @{2 * 1.2 * $n / $d@}]
|
||||||
3.24891518738
|
3.24891518738
|
||||||
@end example
|
@end example
|
||||||
@end deffn
|
@end deffn
|
||||||
|
@ -4523,13 +4525,13 @@ where the mask bit is 1. The following example sets HPROT3 (cacheable)
|
||||||
and leaves the rest of the pattern intact. It configures memory access through
|
and leaves the rest of the pattern intact. It configures memory access through
|
||||||
DCache on Cortex-M7.
|
DCache on Cortex-M7.
|
||||||
@example
|
@example
|
||||||
set CSW_HPROT3_CACHEABLE [expr 1 << 27]
|
set CSW_HPROT3_CACHEABLE [expr @{1 << 27@}]
|
||||||
samv.dap apcsw $CSW_HPROT3_CACHEABLE $CSW_HPROT3_CACHEABLE
|
samv.dap apcsw $CSW_HPROT3_CACHEABLE $CSW_HPROT3_CACHEABLE
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
Another example clears SPROT bit and leaves the rest of pattern intact:
|
Another example clears SPROT bit and leaves the rest of pattern intact:
|
||||||
@example
|
@example
|
||||||
set CSW_SPROT [expr 1 << 30]
|
set CSW_SPROT [expr @{1 << 30@}]
|
||||||
samv.dap apcsw 0 $CSW_SPROT
|
samv.dap apcsw 0 $CSW_SPROT
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
|
@ -8620,7 +8622,7 @@ In addition the following arguments may be specified:
|
||||||
proc load_image_bin @{fname foffset address length @} @{
|
proc load_image_bin @{fname foffset address length @} @{
|
||||||
# Load data from fname filename at foffset offset to
|
# Load data from fname filename at foffset offset to
|
||||||
# target at address. Load at most length bytes.
|
# target at address. Load at most length bytes.
|
||||||
load_image $fname [expr $address - $foffset] bin \
|
load_image $fname [expr @{$address - $foffset@}] bin \
|
||||||
$address $length
|
$address $length
|
||||||
@}
|
@}
|
||||||
@end example
|
@end example
|
||||||
|
@ -10402,7 +10404,7 @@ trivial challenge-response protocol could be implemented as follows in a
|
||||||
configuration file, immediately following @command{init}:
|
configuration file, immediately following @command{init}:
|
||||||
@example
|
@example
|
||||||
set challenge [riscv authdata_read]
|
set challenge [riscv authdata_read]
|
||||||
riscv authdata_write [expr $challenge + 1]
|
riscv authdata_write [expr @{$challenge + 1@}]
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@deffn {Command} {riscv authdata_read}
|
@deffn {Command} {riscv authdata_read}
|
||||||
|
@ -12111,7 +12113,7 @@ it reads a file and executes as a script.
|
||||||
@example
|
@example
|
||||||
set x 6
|
set x 6
|
||||||
set y 7
|
set y 7
|
||||||
puts [format "The answer: %d" [expr $x * $y]]
|
puts [format "The answer: %d" [expr @{$x * $y@}]]
|
||||||
@end example
|
@end example
|
||||||
@enumerate
|
@enumerate
|
||||||
@item The SET command creates 2 variables, X and Y.
|
@item The SET command creates 2 variables, X and Y.
|
||||||
|
@ -12182,13 +12184,13 @@ proc myproc @{ @} @{
|
||||||
@b{Dynamic variable creation}
|
@b{Dynamic variable creation}
|
||||||
@example
|
@example
|
||||||
# Dynamically create a bunch of variables.
|
# Dynamically create a bunch of variables.
|
||||||
for @{ set x 0 @} @{ $x < 32 @} @{ set x [expr $x + 1]@} @{
|
for @{ set x 0 @} @{ $x < 32 @} @{ set x [expr @{$x + 1@}]@} @{
|
||||||
# Create var name
|
# Create var name
|
||||||
set vn [format "BIT%d" $x]
|
set vn [format "BIT%d" $x]
|
||||||
# Make it a global
|
# Make it a global
|
||||||
global $vn
|
global $vn
|
||||||
# Set it.
|
# Set it.
|
||||||
set $vn [expr (1 << $x)]
|
set $vn [expr @{1 << $x@}]
|
||||||
@}
|
@}
|
||||||
@end example
|
@end example
|
||||||
@b{Dynamic proc/command creation}
|
@b{Dynamic proc/command creation}
|
||||||
|
|
Loading…
Reference in New Issue