56abb29e37acba264377da91b05564c775983824
[fw/openocd] / src / tcl / chip / atmel / at91 / rtt.tcl
1
2 set RTTC_RTMR [expr $AT91C_BASE_RTTC + 0x00]
3 set RTTC_RTAR [expr $AT91C_BASE_RTTC + 0x04]
4 set RTTC_RTVR [expr $AT91C_BASE_RTTC + 0x08]
5 set RTTC_RTSR [expr $AT91C_BASE_RTTC + 0x0c]
6 global RTTC_RTMR
7 global RTTC_RTAR
8 global RTTC_RTVR
9 global RTTC_RTSR
10
11 proc show_RTTC_RTMR_helper { NAME ADDR VAL } {
12     set rtpres [expr $VAL & 0x0ffff]
13     global BIT16 BIT17
14     if { $rtpres == 0 } {
15         set rtpres 65536;
16     } 
17     global AT91C_SLOWOSC_FREQ
18     set f [expr double($AT91C_SLOWOSC_FREQ) / double($rtpres)]
19     puts [format "\tPrescale value: 0x%04x (%5d) => %f Hz" $rtpres $rtpres $f]
20     if { $VAL & $BIT16 } {
21         puts "\tBit16 -> Alarm IRQ Enabled"
22     } else {
23         puts "\tBit16 -> Alarm IRQ Disabled"
24     }
25     if { $VAL & $BIT17 } {
26         puts "\tBit17 -> RTC Inc IRQ Enabled"
27     } else {
28         puts "\tBit17 -> RTC Inc IRQ Disabled"
29     }
30     # Bit 18 is write only.
31 }
32
33 proc show_RTTC_RTSR_helper { NAME ADDR VAL } {
34     global BIT0 BIT1
35     if { $VAL & $BIT0 } {
36         puts "\tBit0 -> ALARM PENDING"
37     } else {
38         puts "\tBit0 -> alarm not pending"
39     }
40     if { $VAL & $BIT1 } {
41         puts "\tBit0 -> RTINC PENDING"
42     } else {
43         puts "\tBit0 -> rtinc not pending"
44     }
45 }
46
47 proc show_RTTC { } {
48     
49     show_mmr32_reg RTTC_RTMR
50     show_mmr32_reg RTTC_RTAR
51     show_mmr32_reg RTTC_RTVR
52     show_mmr32_reg RTTC_RTSR
53 }
54