1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2009 by Maurus Cuelenaere
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
24 #include "debug-target.h"
31 #include "timefuncs.h"
34 static void printf(const char *format
, ...)
43 len
= vsnprintf(ptr
, sizeof(printfbuf
), format
, ap
);
46 lcd_puts(0, line
++, ptr
);
50 * Clock Generation Module
52 #define TO_MHZ(x) ((x)/1000000), ((x)%1000000)/10000
53 #define TO_KHZ(x) ((x)/1000), ((x)%1000)/10
55 static void display_clocks(void)
57 unsigned int cppcr
= REG_CPM_CPPCR
; /* PLL Control Register */
58 unsigned int cpccr
= REG_CPM_CPCCR
; /* Clock Control Register */
59 unsigned int div
[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32};
60 unsigned int od
[4] = {1, 2, 2, 4};
62 printf("CPPCR : 0x%08x", cppcr
);
63 printf("CPCCR : 0x%08x", cpccr
);
64 printf("PLL : %s", (cppcr
& CPM_CPPCR_PLLEN
) ? "ON" : "OFF");
65 printf("m:n:o : %d:%d:%d",
70 printf("C:H:M:P : %d:%d:%d:%d",
71 div
[__cpm_get_cdiv()],
72 div
[__cpm_get_hdiv()],
73 div
[__cpm_get_mdiv()],
76 printf("U:L:I:P:M : %d:%d:%d:%d:%d",
83 printf("PLL Freq: %3d.%02d MHz", TO_MHZ(__cpm_get_pllout()));
84 printf("CCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_cclk()));
85 printf("HCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_hclk()));
86 printf("MCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_mclk()));
87 printf("PCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_pclk()));
88 printf("LCDCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_lcdclk()));
89 printf("PIXCLK : %6d.%02d KHz", TO_KHZ(__cpm_get_pixclk()));
90 printf("I2SCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_i2sclk()));
91 printf("USBCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_usbclk()));
92 printf("MSCCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_mscclk()));
93 printf("EXTALCLK: %3d.%02d MHz", TO_MHZ(__cpm_get_extalclk()));
94 printf("RTCCLK : %3d.%02d KHz", TO_KHZ(__cpm_get_rtcclk()));
97 static void display_enabled_clocks(void)
99 unsigned long lcr
= REG_CPM_LCR
;
100 unsigned long clkgr
= REG_CPM_CLKGR
;
102 printf("Low Power Mode : %s",
103 ((lcr
& CPM_LCR_LPM_MASK
) == CPM_LCR_LPM_IDLE
) ?
104 "IDLE" : (((lcr
& CPM_LCR_LPM_MASK
) == CPM_LCR_LPM_SLEEP
) ? "SLEEP" : "HIBERNATE")
107 printf("Doze Mode : %s",
108 (lcr
& CPM_LCR_DOZE_ON
) ? "ON" : "OFF");
109 if (lcr
& CPM_LCR_DOZE_ON
)
110 printf(" duty : %d", (int)((lcr
& CPM_LCR_DOZE_DUTY_MASK
) >> CPM_LCR_DOZE_DUTY_BIT
));
113 (clkgr
& CPM_CLKGR_IPU
) ? "stopped" : "running");
115 (clkgr
& CPM_CLKGR_DMAC
) ? "stopped" : "running");
117 (clkgr
& CPM_CLKGR_UHC
) ? "stopped" : "running");
119 (clkgr
& CPM_CLKGR_UDC
) ? "stopped" : "running");
121 (clkgr
& CPM_CLKGR_LCD
) ? "stopped" : "running");
123 (clkgr
& CPM_CLKGR_CIM
) ? "stopped" : "running");
125 (clkgr
& CPM_CLKGR_SADC
) ? "stopped" : "running");
127 (clkgr
& CPM_CLKGR_MSC
) ? "stopped" : "running");
129 (clkgr
& CPM_CLKGR_AIC1
) ? "stopped" : "running");
131 (clkgr
& CPM_CLKGR_AIC2
) ? "stopped" : "running");
133 (clkgr
& CPM_CLKGR_SSI
) ? "stopped" : "running");
135 (clkgr
& CPM_CLKGR_I2C
) ? "stopped" : "running");
137 (clkgr
& CPM_CLKGR_RTC
) ? "stopped" : "running");
139 (clkgr
& CPM_CLKGR_TCU
) ? "stopped" : "running");
141 (clkgr
& CPM_CLKGR_UART1
) ? "stopped" : "running");
143 (clkgr
& CPM_CLKGR_UART0
) ? "stopped" : "running");
146 bool __dbg_ports(void)
151 bool __dbg_hw_info(void)
154 #ifdef HAVE_TOUCHSCREEN
159 lcd_setfont(FONT_SYSFIXED
);
160 while(btn
^ BUTTON_POWER
)
165 display_enabled_clocks();
166 #ifdef HAVE_TOUCHSCREEN
167 btn
= button_read_device(&touch
);
168 printf("X: %d Y: %d BTN: 0x%X", touch
>>16, touch
&0xFFFF, btn
);
170 btn
= button_read_device();
172 cur_time
= get_time();
173 printf("%02d/%02d/%04d %02d:%02d:%02d", cur_time
->tm_mday
,
174 cur_time
->tm_mon
, cur_time
->tm_year
, cur_time
->tm_hour
,
175 cur_time
->tm_min
, cur_time
->tm_sec
);