tcl: add SPDX tag
[openocd.git] / tcl / chip / atmel / at91 / usarts.tcl
1 # SPDX-License-Identifier: GPL-2.0-or-later
2
3 # the DBGU and USARTs are 'almost' indentical'
4 set DBGU_CR [expr {$AT91C_BASE_DBGU + 0x00000000}]
5 set DBGU_MR [expr {$AT91C_BASE_DBGU + 0x00000004}]
6 set DBGU_IER [expr {$AT91C_BASE_DBGU + 0x00000008}]
7 set DBGU_IDR [expr {$AT91C_BASE_DBGU + 0x0000000C}]
8 set DBGU_IMR [expr {$AT91C_BASE_DBGU + 0x00000010}]
9 set DBGU_CSR [expr {$AT91C_BASE_DBGU + 0x00000014}]
10 set DBGU_RHR [expr {$AT91C_BASE_DBGU + 0x00000018}]
11 set DBGU_THR [expr {$AT91C_BASE_DBGU + 0x0000001C}]
12 set DBGU_BRGR [expr {$AT91C_BASE_DBGU + 0x00000020}]
13 # no RTOR
14 # no TTGR
15 # no FIDI
16 # no NER
17 set DBGU_CIDR [expr {$AT91C_BASE_DBGU + 0x00000040}]
18 set DBGU_EXID [expr {$AT91C_BASE_DBGU + 0x00000044}]
19 set DBGU_FNTR [expr {$AT91C_BASE_DBGU + 0x00000048}]
20
21
22 set USx_CR 0x00000000
23 set USx_MR 0x00000004
24 set USx_IER 0x00000008
25 set USx_IDR 0x0000000C
26 set USx_IMR 0x00000010
27 set USx_CSR 0x00000014
28 set USx_RHR 0x00000018
29 set USx_THR 0x0000001C
30 set USx_BRGR 0x00000020
31 set USx_RTOR 0x00000024
32 set USx_TTGR 0x00000028
33 set USx_FIDI 0x00000040
34 set USx_NER 0x00000044
35 set USx_IF 0x0000004C
36
37 # Create all the uarts that exist..
38 # we blow up if there are >9
39
40
41 proc show_mmr_USx_MR_helper { NAME ADDR VAL } {
42 # First - just print it
43
44 set x [show_normalize_bitfield $VAL 3 0]
45 if { $x == 0 } {
46 echo "\tNormal operation"
47 } else {
48 echo [format "\tNon Normal operation mode: 0x%02x" $x]
49 }
50
51 set x [show_normalize_bitfield $VAL 11 9]
52 set s "unknown"
53 switch -exact $x {
54 0 { set s "Even" }
55 1 { set s "Odd" }
56 2 { set s "Force=0" }
57 3 { set s "Force=1" }
58 * {
59 set $x [expr {$x & 6}]
60 switch -exact $x {
61 4 { set s "None" }
62 6 { set s "Multidrop Mode" }
63 }
64 }
65 }
66 echo [format "\tParity: %s " $s]
67
68 set x [expr {5 + [show_normalize_bitfield $VAL 7 6]}]
69 echo [format "\tDatabits: %d" $x]
70
71 set x [show_normalize_bitfield $VAL 13 12]
72 switch -exact $x {
73 0 { echo "\tStop bits: 1" }
74 1 { echo "\tStop bits: 1.5" }
75 2 { echo "\tStop bits: 2" }
76 3 { echo "\tStop bits: Illegal/Reserved" }
77 }
78 }
79
80 # For every possbile usart...
81 foreach WHO { US0 US1 US2 US3 US4 US5 US6 US7 US8 US9 } {
82 set n AT91C_BASE_[set WHO]
83 set str ""
84
85 # Only if it exists on the chip
86 if [ info exists $n ] {
87 # Hence: $n - is like AT91C_BASE_USx
88 # For every sub-register
89 foreach REG {CR MR IER IDR IMR CSR RHR THR BRGR RTOR TTGR FIDI NER IF} {
90 # vn = variable name
91 set vn [set WHO]_[set REG]
92 # vn = USx_IER
93 # vv = variable value
94 set vv [expr "$$n + [set USx_[set REG]]"]
95 # And VV is the address in memory of that register
96
97
98 # make that VN a GLOBAL so others can find it
99 global $vn
100 set $vn $vv
101
102 # Create a command for this specific register.
103 proc show_$vn { } "show_mmr32_reg $vn"
104
105 # Add this command to the Device(as a whole) command
106 set str "$str\nshow_$vn"
107 }
108 # Now - create the DEVICE(as a whole) command
109 set fn show_$WHO
110 proc $fn { } $str
111 }
112 }
113
114 # The Debug Uart is special..
115 set str ""
116
117
118 # For every sub-register
119 foreach REG {DBGU_CR DBGU_MR DBGU_IER DBGU_IDR DBGU_IMR
120 DBGU_CSR DBGU_RHR DBGU_THR DBGU_BRGR DBGU_CIDR DBGU_EXID DBGU_FNTR} {
121
122 # Create a command for this specific register.
123 proc show_$REG { } "show_mmr32_reg $REG"
124
125 # Add this command to the Device(as a whole) command
126 set str "$str\nshow_$REG"
127 }
128
129 # Now - create the DEVICE(as a whole) command
130 proc show_DBGU { } $str
131
132 unset str
133
134 proc show_DBGU_MR_helper { NAME ADDR VAL } { show_mmr_USx_MR_helper $NAME $ADDR $VAL }

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)