You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

136 lines
3.6 KiB

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