1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
diff --git a/firmware/target/arm/as3525/debug-as3525.c b/firmware/target/arm/as3525/debug-as3525.c
index 405b710..b652cef 100644
--- a/firmware/target/arm/as3525/debug-as3525.c
+++ b/firmware/target/arm/as3525/debug-as3525.c
@@ -28,6 +28,7 @@
 #include "sprintf.h"
 #include "cpu.h"
 #include "pl180.h"
+#include "timer-target.h"

 #define _DEBUG_PRINTF(a,varargs...) \
     snprintf(buf, sizeof(buf), (a), ##varargs); lcd_puts(0,line++,buf)
@@ -347,6 +348,7 @@ bool __dbg_ports(void)
     lcd_clear_display();
     lcd_setfont(FONT_SYSFIXED);

+#if 0
     while(1)
     {
         line = 0;
@@ -367,6 +369,69 @@ bool __dbg_ports(void)
         if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL))
             break;
     }
+#else
+    static int i_test[512] IBSS_ATTR;
+    static int d_test[512];
+    int x,y;
+    int ir_stop,iw_stop,dr_stop,dw_stop;
+
+#define max (1<<20)
+
+    asm volatile(
+    "mrc p15, 0, r0, c1, c0     \n"
+    "bic r0, r0, #1<<2  @dcache \n"
+    "mcr p15, 0, r0, c1, c0     \n"
+    : : : "r0");
+
+    disable_irq();
+
+    CGU_PERI |= CGU_TIMER1_CLOCK_ENABLE;    /* enable peripheral */
+    TIMER1_CONTROL =  (TIMER1_CONTROL & (1<<4)) |
+                         TIMER_ENABLE |
+                         TIMER_PERIODIC |
+                         TIMER_32_BIT;
+
+    TIMER1_LOAD = TIMER1_BGLOAD = TIMER_FREQ;   /* 1s */
+    for(x = 0; x < max ; x++)
+        i_test[x%512] = x;
+    iw_stop = TIMER1_VALUE;
+    TIMER1_LOAD = TIMER1_BGLOAD = TIMER_FREQ;   /* 1s */
+
+    for(x = 0; x < max ; x++)
+        d_test[x%512] = x;
+    dw_stop = TIMER1_VALUE;
+    TIMER1_LOAD = TIMER1_BGLOAD = TIMER_FREQ;   /* 1s */
+
+    for(x = 0; x < max ; x++)
+        y = i_test[x%512];
+    ir_stop = TIMER1_VALUE;
+    TIMER1_LOAD = TIMER1_BGLOAD = TIMER_FREQ;   /* 1s */
+
+    for(x = 0; x < max ; x++)
+        y = d_test[x%512];
+    dr_stop = TIMER1_VALUE;
+
+    TIMER1_CONTROL &= 0x10; /* disable timer 1 (don't modify bit 4) */
+
+    asm volatile(
+    "mrc p15, 0, r0, c1, c0     \n"
+    "orr r0, r0, #1<<2  @dcache \n"
+    "mcr p15, 0, r0, c1, c0     \n"
+    : : : "r0");
+
+    enable_irq();
+
+    line = 0;
+    _DEBUG_PRINTF("IRAM R %d cycles", TIMER_FREQ - ir_stop);
+    _DEBUG_PRINTF("IRAM W %d cycles", TIMER_FREQ - iw_stop);
+    _DEBUG_PRINTF("DRAM R %d cycles", TIMER_FREQ - dr_stop);
+    _DEBUG_PRINTF("DRAM W %d cycles", TIMER_FREQ - dw_stop);
+    lcd_update();
+
+
+    while(button_get_w_tmo(HZ/10) != (DEBUG_CANCEL|BUTTON_REL)) ;
+
+#endif
     lcd_setfont(FONT_UI);
     return false;
 }