1 # the DBGU and USARTs are 'almost' indentical'
2 set DBGU_CR
[expr $AT91C_BASE_DBGU + 0x00000000]
3 set DBGU_MR
[expr $AT91C_BASE_DBGU + 0x00000004]
4 set DBGU_IER
[expr $AT91C_BASE_DBGU + 0x00000008]
5 set DBGU_IDR
[expr $AT91C_BASE_DBGU + 0x0000000C]
6 set DBGU_IMR
[expr $AT91C_BASE_DBGU + 0x00000010]
7 set DBGU_CSR
[expr $AT91C_BASE_DBGU + 0x00000014]
8 set DBGU_RHR
[expr $AT91C_BASE_DBGU + 0x00000018]
9 set DBGU_THR
[expr $AT91C_BASE_DBGU + 0x0000001C]
10 set DBGU_BRGR
[expr $AT91C_BASE_DBGU + 0x00000020]
15 set DBGU_CIDR
[expr $AT91C_BASE_DBGU + 0x00000040]
16 set DBGU_EXID
[expr $AT91C_BASE_DBGU + 0x00000044]
17 set DBGU_FNTR
[expr $AT91C_BASE_DBGU + 0x00000048]
22 set USx_IER
0x00000008
23 set USx_IDR
0x0000000C
24 set USx_IMR
0x00000010
25 set USx_CSR
0x00000014
26 set USx_RHR
0x00000018
27 set USx_THR
0x0000001C
28 set USx_BRGR
0x00000020
29 set USx_RTOR
0x00000024
30 set USx_TTGR
0x00000028
31 set USx_FIDI
0x00000040
32 set USx_NER
0x00000044
35 # Create all the uarts that exist..
36 # we blow up if there are >9
39 proc show_mmr_USx_MR_helper
{ NAME ADDR VAL
} {
40 # First - just print it
42 set x
[show_normalize_bitfield
$VAL 3 0]
44 echo
"\tNormal operation"
46 echo
[format "\tNon Normal operation mode: 0x%02x" $x]
49 set x
[show_normalize_bitfield
$VAL 11 9]
60 6 { set s
"Multidrop Mode" }
64 echo
[format "\tParity: %s " $s]
66 set x
[expr 5 + [show_normalize_bitfield
$VAL 7 6]]
67 echo
[format "\tDatabits: %d" $x]
69 set x
[show_normalize_bitfield
$VAL 13 12]
71 0 { echo
"\tStop bits: 1" }
72 1 { echo
"\tStop bits: 1.5" }
73 2 { echo
"\tStop bits: 2" }
74 3 { echo
"\tStop bits: Illegal/Reserved" }
78 # For every possbile usart...
79 foreach WHO
{ US0 US1 US2 US3 US4 US5 US6 US7 US8 US9
} {
80 set n AT91C_BASE_
[set WHO
]
83 # Only if it exists on the chip
84 if [ info exists
$n ] {
85 # Hence: $n - is like AT91C_BASE_USx
86 # For every sub-register
87 foreach REG
{CR MR IER IDR IMR CSR RHR THR BRGR RTOR TTGR FIDI NER IF
} {
89 set vn
[set WHO
]_
[set REG
]
92 set vv
[expr $$n + [set USx_
[set REG
]]]
93 # And VV is the address in memory of that register
96 # make that VN a GLOBAL so others can find it
100 # Create a command for this specific register.
101 proc show_
$vn { } "show_mmr32_reg $vn"
103 # Add this command to the Device(as a whole) command
104 set str
"$str\nshow_$vn"
106 # Now - create the DEVICE(as a whole) command
112 # The Debug Uart is special..
116 # For every sub-register
117 foreach REG
{DBGU_CR DBGU_MR DBGU_IER DBGU_IDR DBGU_IMR
118 DBGU_CSR DBGU_RHR DBGU_THR DBGU_BRGR DBGU_CIDR DBGU_EXID DBGU_FNTR
} {
120 # Create a command for this specific register.
121 proc show_
$REG { } "show_mmr32_reg $REG"
123 # Add this command to the Device(as a whole) command
124 set str
"$str\nshow_$REG"
127 # Now - create the DEVICE(as a whole) command
128 proc show_DBGU
{ } $str
132 proc show_DBGU_MR_helper
{ NAME ADDR VAL
} { show_mmr_USx_MR_helper
$NAME $ADDR $VAL }