Commit whole Creative Zen Vision:M target tree + all related firmware/
[Rockbox.git] / firmware / target / arm / tms320dm320 / debug-dm320.c
blobabfb5b09bc965a5a303049d2e5be342a9f441d84
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007 by Karl Kurbjun
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "config.h"
21 #include "cpu.h"
22 #include "system.h"
23 #include "string.h"
24 #include <stdbool.h>
25 #include "button.h"
26 #include "lcd.h"
27 #include "sprintf.h"
28 #include "font.h"
29 #include "debug-target.h"
30 #include "lcd-target.h"
32 bool __dbg_ports(void)
34 return false;
37 #ifndef CREATIVE_ZVM
38 extern char r_buffer[5];
39 extern int r_button;
40 #endif
41 bool __dbg_hw_info(void)
43 int line = 0, oldline;
44 int button;
45 #ifndef CREATIVE_ZVM
46 int *address=0x0;
47 #endif
48 bool done=false;
49 char buf[100];
51 lcd_setmargins(0, 0);
52 lcd_setfont(FONT_SYSFIXED);
53 lcd_clear_display();
55 /* Put all the static text befor the while loop */
56 lcd_puts(0, line++, "[Hardware info]");
58 lcd_puts(0, line++, "Clock info:");
59 #if LCD_WIDTH > 320
60 snprintf(buf, sizeof(buf), "IO_CLK_PLLA: 0x%04x IO_CLK_PLLB: 0x%04x IO_CLK_SEL0: 0x%04x IO_CLK_SEL1: 0x%04x",
61 IO_CLK_PLLA, IO_CLK_PLLB, IO_CLK_SEL0, IO_CLK_SEL1); lcd_puts(0, line++, buf);
62 snprintf(buf, sizeof(buf), "IO_CLK_SEL2: 0x%04x IO_CLK_DIV0: 0x%04x IO_CLK_DIV1: 0x%04x IO_CLK_DIV2: 0x%04x",
63 IO_CLK_SEL2, IO_CLK_DIV0, IO_CLK_DIV1, IO_CLK_DIV2); lcd_puts(0, line++, buf);
64 snprintf(buf, sizeof(buf), "IO_CLK_DIV3: 0x%04x IO_CLK_DIV4: 0x%04x IO_CLK_BYP : 0x%04x IO_CLK_INV : 0x%04x",
65 IO_CLK_DIV3, IO_CLK_DIV4, IO_CLK_BYP, IO_CLK_INV); lcd_puts(0, line++, buf);
66 snprintf(buf, sizeof(buf), "IO_CLK_MOD0: 0x%04x IO_CLK_MOD1: 0x%04x IO_CLK_MOD2: 0x%04x IO_CLK_LPCTL0: 0x%04x",
67 IO_CLK_MOD0, IO_CLK_MOD1, IO_CLK_MOD2, IO_CLK_LPCTL0); lcd_puts(0, line++, buf);
68 #else
69 snprintf(buf, sizeof(buf), " IO_CLK_PLLA: 0x%04x IO_CLK_PLLB: 0x%04x", IO_CLK_PLLA, IO_CLK_PLLB);
70 lcd_puts(0, line++, buf);
71 snprintf(buf, sizeof(buf), " IO_CLK_SEL0: 0x%04x IO_CLK_SEL1: 0x%04x", IO_CLK_SEL0, IO_CLK_SEL1);
72 lcd_puts(0, line++, buf);
73 snprintf(buf, sizeof(buf), " IO_CLK_SEL2: 0x%04x IO_CLK_DIV0: 0x%04x", IO_CLK_SEL2, IO_CLK_DIV0);
74 lcd_puts(0, line++, buf);
75 snprintf(buf, sizeof(buf), " IO_CLK_DIV1: 0x%04x IO_CLK_DIV2: 0x%04x", IO_CLK_DIV1, IO_CLK_DIV2);
76 lcd_puts(0, line++, buf);
77 snprintf(buf, sizeof(buf), " IO_CLK_DIV3: 0x%04x IO_CLK_DIV4: 0x%04x", IO_CLK_DIV3, IO_CLK_DIV4);
78 lcd_puts(0, line++, buf);
79 snprintf(buf, sizeof(buf), " IO_CLK_BYP : 0x%04x IO_CLK_INV : 0x%04x", IO_CLK_BYP, IO_CLK_INV);
80 lcd_puts(0, line++, buf);
81 snprintf(buf, sizeof(buf), " IO_CLK_MOD0: 0x%04x IO_CLK_MOD1: 0x%04x ", IO_CLK_MOD0, IO_CLK_MOD1);
82 lcd_puts(0, line++, buf);
83 snprintf(buf, sizeof(buf), " IO_CLK_MOD2: 0x%04x IO_CLK_LPCTL0: 0x%04x ", IO_CLK_MOD2, IO_CLK_LPCTL0);
84 lcd_puts(0, line++, buf);
85 #endif
87 lcd_puts(0, line++, "Board revision:");
88 switch (IO_BUSC_REVR) {
89 case 0x0010:
90 lcd_puts(0, line++, " DM320 Rev. A");
91 break;
92 case 0x0011:
93 lcd_puts(0, line++, " DM320 Rev. B/C");
94 break;
95 default:
96 lcd_puts(0, line++, " Unknown DM320 Chip ID");
99 #ifndef CREATIVE_ZVM
100 line++;
101 #endif
102 oldline=line;
103 while(!done)
105 line = oldline;
106 #ifndef CREATIVE_ZVM
107 button = button_get(false);
108 button&=~BUTTON_REPEAT;
109 if (button == BUTTON_POWER)
110 done=true;
111 if(button==BUTTON_RC_PLAY)
112 address+=0x01;
113 else if (button==BUTTON_RC_DOWN)
114 address-=0x01;
115 else if (button==BUTTON_RC_FF)
116 address+=0x800;
117 else if (button==BUTTON_RC_REW)
118 address-=0x800;
120 snprintf(buf, sizeof(buf), "Buffer: 0x%02x%02x%02x%02x%02x",
121 r_buffer[0], r_buffer[1], r_buffer[2], r_buffer[3],r_buffer[4] ); lcd_puts(0, line++, buf);
122 snprintf(buf, sizeof(buf), "Button: 0x%08x, HWread: 0x%08x",
123 (unsigned int)button, r_button); lcd_puts(0, line++, buf);
124 #else
125 button = button_get(false);
126 if(button & BUTTON_POWER)
127 done = true;
128 else if(button & BUTTON_LEFT)
129 lcd_set_direct_fb(false);
130 else if(button & BUTTON_RIGHT)
131 lcd_set_direct_fb(true);
133 lcd_puts(0, line++, "PIC info:");
134 snprintf(buf, sizeof(buf), " Init value 1: 0x%04x", get_debug_info(1));
135 lcd_puts(0, line++, buf);
136 snprintf(buf, sizeof(buf), " Init value 2: 0x%04x", get_debug_info(2));
137 lcd_puts(0, line++, buf);
138 snprintf(buf, sizeof(buf), " Last button value: 0x%04x Raw value: 0x%04x", get_debug_info(3), button_read_device());
139 lcd_puts(0, line++, buf);
140 snprintf(buf, sizeof(buf), " Last button at: 0x%04x", get_debug_info(5));
141 lcd_puts(0, line++, buf);
142 snprintf(buf, sizeof(buf), " Dock values: 0x%04x", get_debug_info(4));
143 lcd_puts(0, line++, buf);
144 lcd_puts(0, line++, "LCD info:");
145 snprintf(buf, sizeof(buf), " LCD direct FB access? %s", (lcd_get_direct_fb() ? "yes" : "no"));
146 lcd_puts(0, line++, buf);
147 line++;
148 #endif
149 lcd_puts(0, line++, "[Rockbox info]");
150 snprintf(buf, sizeof(buf), "current tick: %08x Seconds running: %08d",
151 (unsigned int)current_tick, (unsigned int)current_tick/100); lcd_puts(0, line++, buf);
152 #ifndef CREATIVE_ZVM
153 snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x",
154 (unsigned int)address, *address); lcd_puts(0, line++, buf);
155 snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x",
156 (unsigned int)(address+1), *(address+1)); lcd_puts(0, line++, buf);
157 snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x",
158 (unsigned int)(address+2), *(address+2)); lcd_puts(0, line++, buf);
159 #endif
161 lcd_update();
163 return false;