Karl Kurbjun | 0082da7 | 2007-11-10 22:16:15 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2007 by Karl Kurbjun |
| 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 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. |
Karl Kurbjun | 0082da7 | 2007-11-10 22:16:15 +0000 | [diff] [blame] | 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | ****************************************************************************/ |
| 21 | |
| 22 | #include "config.h" |
| 23 | #include "cpu.h" |
| 24 | #include "system.h" |
| 25 | #include "string.h" |
| 26 | #include <stdbool.h> |
| 27 | #include "button.h" |
| 28 | #include "lcd.h" |
| 29 | #include "sprintf.h" |
| 30 | #include "font.h" |
| 31 | #include "debug-target.h" |
Maurus Cuelenaere | 95167e0 | 2008-04-24 20:08:28 +0000 | [diff] [blame] | 32 | #include "lcd-target.h" |
Karl Kurbjun | 0082da7 | 2007-11-10 22:16:15 +0000 | [diff] [blame] | 33 | |
Karl Kurbjun | d185f9e | 2007-11-10 23:13:27 +0000 | [diff] [blame] | 34 | bool __dbg_ports(void) |
| 35 | { |
| 36 | return false; |
| 37 | } |
| 38 | |
Maurus Cuelenaere | e031db4 | 2008-05-14 18:55:19 +0000 | [diff] [blame] | 39 | #ifndef CREATIVE_ZVx |
Karl Kurbjun | d3d0b26 | 2007-11-15 06:44:35 +0000 | [diff] [blame] | 40 | extern char r_buffer[5]; |
| 41 | extern int r_button; |
Maurus Cuelenaere | 95167e0 | 2008-04-24 20:08:28 +0000 | [diff] [blame] | 42 | #endif |
Karl Kurbjun | 0082da7 | 2007-11-10 22:16:15 +0000 | [diff] [blame] | 43 | bool __dbg_hw_info(void) |
| 44 | { |
Maurus Cuelenaere | 95167e0 | 2008-04-24 20:08:28 +0000 | [diff] [blame] | 45 | int line = 0, oldline; |
| 46 | int button; |
Maurus Cuelenaere | e031db4 | 2008-05-14 18:55:19 +0000 | [diff] [blame] | 47 | #ifndef CREATIVE_ZVx |
Karl Kurbjun | 0082da7 | 2007-11-10 22:16:15 +0000 | [diff] [blame] | 48 | int *address=0x0; |
Maurus Cuelenaere | 95167e0 | 2008-04-24 20:08:28 +0000 | [diff] [blame] | 49 | #endif |
Karl Kurbjun | 0082da7 | 2007-11-10 22:16:15 +0000 | [diff] [blame] | 50 | bool done=false; |
| 51 | char buf[100]; |
Karl Kurbjun | d3d0b26 | 2007-11-15 06:44:35 +0000 | [diff] [blame] | 52 | |
Karl Kurbjun | 0082da7 | 2007-11-10 22:16:15 +0000 | [diff] [blame] | 53 | lcd_setfont(FONT_SYSFIXED); |
| 54 | lcd_clear_display(); |
Karl Kurbjun | d3d0b26 | 2007-11-15 06:44:35 +0000 | [diff] [blame] | 55 | |
Karl Kurbjun | 59a2862 | 2007-11-11 03:31:24 +0000 | [diff] [blame] | 56 | /* Put all the static text befor the while loop */ |
Karl Kurbjun | 0082da7 | 2007-11-10 22:16:15 +0000 | [diff] [blame] | 57 | lcd_puts(0, line++, "[Hardware info]"); |
Karl Kurbjun | d3d0b26 | 2007-11-15 06:44:35 +0000 | [diff] [blame] | 58 | |
Karl Kurbjun | 59a2862 | 2007-11-11 03:31:24 +0000 | [diff] [blame] | 59 | lcd_puts(0, line++, "Clock info:"); |
Maurus Cuelenaere | 95167e0 | 2008-04-24 20:08:28 +0000 | [diff] [blame] | 60 | #if LCD_WIDTH > 320 |
Karl Kurbjun | 59a2862 | 2007-11-11 03:31:24 +0000 | [diff] [blame] | 61 | snprintf(buf, sizeof(buf), "IO_CLK_PLLA: 0x%04x IO_CLK_PLLB: 0x%04x IO_CLK_SEL0: 0x%04x IO_CLK_SEL1: 0x%04x", |
| 62 | IO_CLK_PLLA, IO_CLK_PLLB, IO_CLK_SEL0, IO_CLK_SEL1); lcd_puts(0, line++, buf); |
| 63 | snprintf(buf, sizeof(buf), "IO_CLK_SEL2: 0x%04x IO_CLK_DIV0: 0x%04x IO_CLK_DIV1: 0x%04x IO_CLK_DIV2: 0x%04x", |
| 64 | IO_CLK_SEL2, IO_CLK_DIV0, IO_CLK_DIV1, IO_CLK_DIV2); lcd_puts(0, line++, buf); |
| 65 | snprintf(buf, sizeof(buf), "IO_CLK_DIV3: 0x%04x IO_CLK_DIV4: 0x%04x IO_CLK_BYP : 0x%04x IO_CLK_INV : 0x%04x", |
| 66 | IO_CLK_DIV3, IO_CLK_DIV4, IO_CLK_BYP, IO_CLK_INV); lcd_puts(0, line++, buf); |
| 67 | snprintf(buf, sizeof(buf), "IO_CLK_MOD0: 0x%04x IO_CLK_MOD1: 0x%04x IO_CLK_MOD2: 0x%04x IO_CLK_LPCTL0: 0x%04x", |
| 68 | IO_CLK_MOD0, IO_CLK_MOD1, IO_CLK_MOD2, IO_CLK_LPCTL0); lcd_puts(0, line++, buf); |
Maurus Cuelenaere | 95167e0 | 2008-04-24 20:08:28 +0000 | [diff] [blame] | 69 | #else |
| 70 | snprintf(buf, sizeof(buf), " IO_CLK_PLLA: 0x%04x IO_CLK_PLLB: 0x%04x", IO_CLK_PLLA, IO_CLK_PLLB); |
| 71 | lcd_puts(0, line++, buf); |
| 72 | snprintf(buf, sizeof(buf), " IO_CLK_SEL0: 0x%04x IO_CLK_SEL1: 0x%04x", IO_CLK_SEL0, IO_CLK_SEL1); |
| 73 | lcd_puts(0, line++, buf); |
| 74 | snprintf(buf, sizeof(buf), " IO_CLK_SEL2: 0x%04x IO_CLK_DIV0: 0x%04x", IO_CLK_SEL2, IO_CLK_DIV0); |
| 75 | lcd_puts(0, line++, buf); |
| 76 | snprintf(buf, sizeof(buf), " IO_CLK_DIV1: 0x%04x IO_CLK_DIV2: 0x%04x", IO_CLK_DIV1, IO_CLK_DIV2); |
| 77 | lcd_puts(0, line++, buf); |
| 78 | snprintf(buf, sizeof(buf), " IO_CLK_DIV3: 0x%04x IO_CLK_DIV4: 0x%04x", IO_CLK_DIV3, IO_CLK_DIV4); |
| 79 | lcd_puts(0, line++, buf); |
| 80 | snprintf(buf, sizeof(buf), " IO_CLK_BYP : 0x%04x IO_CLK_INV : 0x%04x", IO_CLK_BYP, IO_CLK_INV); |
| 81 | lcd_puts(0, line++, buf); |
| 82 | snprintf(buf, sizeof(buf), " IO_CLK_MOD0: 0x%04x IO_CLK_MOD1: 0x%04x ", IO_CLK_MOD0, IO_CLK_MOD1); |
| 83 | lcd_puts(0, line++, buf); |
| 84 | snprintf(buf, sizeof(buf), " IO_CLK_MOD2: 0x%04x IO_CLK_LPCTL0: 0x%04x ", IO_CLK_MOD2, IO_CLK_LPCTL0); |
| 85 | lcd_puts(0, line++, buf); |
Maurus Cuelenaere | ed5f1ed | 2008-05-03 14:43:43 +0000 | [diff] [blame] | 86 | lcd_puts(0, line++, "Interrupt info:"); |
| 87 | snprintf(buf, sizeof(buf), " IO_INTC_EINT0: 0x%04x IO_INTC_EINT1: 0x%04x ", IO_INTC_EINT0, IO_INTC_EINT1); |
| 88 | lcd_puts(0, line++, buf); |
| 89 | snprintf(buf, sizeof(buf), " IO_INTC_EINT2: 0x%04x IO_INTC_IRQ0: 0x%04x ", IO_INTC_EINT2, IO_INTC_IRQ0); |
| 90 | lcd_puts(0, line++, buf); |
| 91 | snprintf(buf, sizeof(buf), " IO_INTC_IRQ1: 0x%04x IO_INTC_IRQ2: 0x%04x ", IO_INTC_IRQ1, IO_INTC_IRQ2); |
| 92 | lcd_puts(0, line++, buf); |
Maurus Cuelenaere | 95167e0 | 2008-04-24 20:08:28 +0000 | [diff] [blame] | 93 | #endif |
| 94 | |
| 95 | lcd_puts(0, line++, "Board revision:"); |
| 96 | switch (IO_BUSC_REVR) { |
| 97 | case 0x0010: |
| 98 | lcd_puts(0, line++, " DM320 Rev. A"); |
| 99 | break; |
| 100 | case 0x0011: |
| 101 | lcd_puts(0, line++, " DM320 Rev. B/C"); |
| 102 | break; |
| 103 | default: |
| 104 | lcd_puts(0, line++, " Unknown DM320 Chip ID"); |
| 105 | } |
Karl Kurbjun | 0082da7 | 2007-11-10 22:16:15 +0000 | [diff] [blame] | 106 | |
Maurus Cuelenaere | e031db4 | 2008-05-14 18:55:19 +0000 | [diff] [blame] | 107 | #ifndef CREATIVE_ZVx |
Karl Kurbjun | 59a2862 | 2007-11-11 03:31:24 +0000 | [diff] [blame] | 108 | line++; |
Maurus Cuelenaere | 95167e0 | 2008-04-24 20:08:28 +0000 | [diff] [blame] | 109 | #endif |
Karl Kurbjun | 59a2862 | 2007-11-11 03:31:24 +0000 | [diff] [blame] | 110 | oldline=line; |
Karl Kurbjun | 0082da7 | 2007-11-10 22:16:15 +0000 | [diff] [blame] | 111 | while(!done) |
| 112 | { |
Karl Kurbjun | 59a2862 | 2007-11-11 03:31:24 +0000 | [diff] [blame] | 113 | line = oldline; |
Maurus Cuelenaere | e031db4 | 2008-05-14 18:55:19 +0000 | [diff] [blame] | 114 | #ifndef CREATIVE_ZVx |
Karl Kurbjun | 0082da7 | 2007-11-10 22:16:15 +0000 | [diff] [blame] | 115 | button = button_get(false); |
| 116 | button&=~BUTTON_REPEAT; |
| 117 | if (button == BUTTON_POWER) |
| 118 | done=true; |
| 119 | if(button==BUTTON_RC_PLAY) |
| 120 | address+=0x01; |
| 121 | else if (button==BUTTON_RC_DOWN) |
| 122 | address-=0x01; |
| 123 | else if (button==BUTTON_RC_FF) |
| 124 | address+=0x800; |
| 125 | else if (button==BUTTON_RC_REW) |
| 126 | address-=0x800; |
| 127 | |
Karl Kurbjun | d3d0b26 | 2007-11-15 06:44:35 +0000 | [diff] [blame] | 128 | snprintf(buf, sizeof(buf), "Buffer: 0x%02x%02x%02x%02x%02x", |
| 129 | r_buffer[0], r_buffer[1], r_buffer[2], r_buffer[3],r_buffer[4] ); lcd_puts(0, line++, buf); |
| 130 | snprintf(buf, sizeof(buf), "Button: 0x%08x, HWread: 0x%08x", |
| 131 | (unsigned int)button, r_button); lcd_puts(0, line++, buf); |
Maurus Cuelenaere | 95167e0 | 2008-04-24 20:08:28 +0000 | [diff] [blame] | 132 | #else |
| 133 | button = button_get(false); |
| 134 | if(button & BUTTON_POWER) |
| 135 | done = true; |
| 136 | else if(button & BUTTON_LEFT) |
| 137 | lcd_set_direct_fb(false); |
| 138 | else if(button & BUTTON_RIGHT) |
| 139 | lcd_set_direct_fb(true); |
| 140 | |
Maurus Cuelenaere | 95167e0 | 2008-04-24 20:08:28 +0000 | [diff] [blame] | 141 | lcd_puts(0, line++, "LCD info:"); |
| 142 | snprintf(buf, sizeof(buf), " LCD direct FB access? %s", (lcd_get_direct_fb() ? "yes" : "no")); |
| 143 | lcd_puts(0, line++, buf); |
| 144 | line++; |
| 145 | #endif |
| 146 | lcd_puts(0, line++, "[Rockbox info]"); |
Karl Kurbjun | 59a2862 | 2007-11-11 03:31:24 +0000 | [diff] [blame] | 147 | snprintf(buf, sizeof(buf), "current tick: %08x Seconds running: %08d", |
| 148 | (unsigned int)current_tick, (unsigned int)current_tick/100); lcd_puts(0, line++, buf); |
Maurus Cuelenaere | e031db4 | 2008-05-14 18:55:19 +0000 | [diff] [blame] | 149 | #ifndef CREATIVE_ZVx |
Karl Kurbjun | 59a2862 | 2007-11-11 03:31:24 +0000 | [diff] [blame] | 150 | snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x", |
| 151 | (unsigned int)address, *address); lcd_puts(0, line++, buf); |
| 152 | snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x", |
| 153 | (unsigned int)(address+1), *(address+1)); lcd_puts(0, line++, buf); |
| 154 | snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x", |
| 155 | (unsigned int)(address+2), *(address+2)); lcd_puts(0, line++, buf); |
Maurus Cuelenaere | 95167e0 | 2008-04-24 20:08:28 +0000 | [diff] [blame] | 156 | #endif |
Karl Kurbjun | 0082da7 | 2007-11-10 22:16:15 +0000 | [diff] [blame] | 157 | |
| 158 | lcd_update(); |
| 159 | } |
| 160 | return false; |
| 161 | } |