drivers/bcm2835gpio: fix usage messages
[openocd.git] / tcl / bitsbytes.tcl
1 #----------------------------------------
2 # Purpose - Create some $BIT variables
3 # Create $K and $M variables
4 # and some bit field extraction variables.
5 # Creat helper variables ...
6 # BIT0.. BIT31
7
8 for { set x 0 } { $x < 32 } { set x [expr $x + 1]} {
9 set vn [format "BIT%d" $x]
10 global $vn
11 set $vn [expr (1 << $x)]
12 }
13
14 # Create K bytes values
15 # __1K ... to __2048K
16 for { set x 1 } { $x < 2048 } { set x [expr $x * 2]} {
17 set vn [format "__%dK" $x]
18 global $vn
19 set $vn [expr (1024 * $x)]
20 }
21
22 # Create M bytes values
23 # __1M ... to __2048K
24 for { set x 1 } { $x < 2048 } { set x [expr $x * 2]} {
25 set vn [format "__%dM" $x]
26 global $vn
27 set $vn [expr (1024 * 1024 * $x)]
28 }
29
30 proc create_mask { MSB LSB } {
31 return [expr (((1 << ($MSB - $LSB + 1))-1) << $LSB)]
32 }
33
34 # Cut Bits $MSB to $LSB out of this value.
35 # Example: % format "0x%08x" [extract_bitfield 0x12345678 27 16]
36 # Result: 0x02340000
37
38 proc extract_bitfield { VALUE MSB LSB } {
39 return [expr [create_mask $MSB $LSB] & $VALUE]
40 }
41
42
43 # Cut bits $MSB to $LSB out of this value
44 # and shift (normalize) them down to bit 0.
45 #
46 # Example: % format "0x%08x" [normalize_bitfield 0x12345678 27 16]
47 # Result: 0x00000234
48 #
49 proc normalize_bitfield { VALUE MSB LSB } {
50 return [expr [extract_bitfield $VALUE $MSB $LSB ] >> $LSB]
51 }
52
53 proc show_normalize_bitfield { VALUE MSB LSB } {
54 set m [create_mask $MSB $LSB]
55 set mr [expr $VALUE & $m]
56 set sr [expr $mr >> $LSB]
57 echo [format "((0x%08x & 0x%08x) -> 0x%08x) >> %2d => (0x%x) %5d " $VALUE $m $mr $LSB $sr $sr]
58 return $sr
59 }
60
61

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)