2002-07-15 11:23:24 +00:00
|
|
|
|
/***************************************************************************
|
|
|
|
|
* __________ __ ___.
|
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2002 Heikki Hannikainen
|
|
|
|
|
*
|
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
|
*
|
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
|
* KIND, either express or implied.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#ifndef SIMULATOR
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdbool.h>
|
2003-08-01 16:05:40 +00:00
|
|
|
|
#include <string.h>
|
2002-07-15 11:23:24 +00:00
|
|
|
|
#include "lcd.h"
|
|
|
|
|
#include "menu.h"
|
|
|
|
|
#include "debug_menu.h"
|
|
|
|
|
#include "kernel.h"
|
|
|
|
|
#include "sprintf.h"
|
|
|
|
|
#include "button.h"
|
|
|
|
|
#include "adc.h"
|
|
|
|
|
#include "mas.h"
|
|
|
|
|
#include "power.h"
|
|
|
|
|
#include "rtc.h"
|
|
|
|
|
#include "debug.h"
|
2002-07-15 22:25:45 +00:00
|
|
|
|
#include "thread.h"
|
2002-08-06 10:52:51 +00:00
|
|
|
|
#include "powermgmt.h"
|
|
|
|
|
#include "system.h"
|
2002-10-08 10:52:46 +00:00
|
|
|
|
#include "font.h"
|
2002-10-10 12:01:58 +00:00
|
|
|
|
#include "disk.h"
|
2005-04-04 12:06:29 +00:00
|
|
|
|
#include "audio.h"
|
2004-03-22 11:48:13 +00:00
|
|
|
|
#include "mp3_playback.h"
|
2002-12-02 16:07:56 +00:00
|
|
|
|
#include "settings.h"
|
2002-12-03 13:12:55 +00:00
|
|
|
|
#include "ata.h"
|
2002-12-09 15:39:32 +00:00
|
|
|
|
#include "fat.h"
|
2004-02-16 12:04:55 +00:00
|
|
|
|
#include "dir.h"
|
|
|
|
|
#include "panic.h"
|
2004-03-25 12:29:34 +00:00
|
|
|
|
#include "screens.h"
|
2004-07-26 16:06:59 +00:00
|
|
|
|
#include "misc.h"
|
2002-10-15 08:08:35 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-10-15 07:23:18 +00:00
|
|
|
|
#include "widgets.h"
|
2002-10-29 12:09:15 +00:00
|
|
|
|
#include "peakmeter.h"
|
2002-10-15 08:08:35 +00:00
|
|
|
|
#endif
|
2004-09-28 22:13:26 +00:00
|
|
|
|
#ifdef CONFIG_TUNER
|
2004-02-05 10:59:51 +00:00
|
|
|
|
#include "radio.h"
|
|
|
|
|
#endif
|
2004-10-06 20:43:12 +00:00
|
|
|
|
#ifdef HAVE_MMC
|
|
|
|
|
#include "ata_mmc.h"
|
|
|
|
|
#endif
|
2005-05-30 13:00:43 +00:00
|
|
|
|
#include "logfdisp.h"
|
2005-06-19 03:05:53 +00:00
|
|
|
|
#if defined(IRIVER_H100) && !defined(SIMULATOR)
|
|
|
|
|
extern bool pcm_rec_screen(void);
|
|
|
|
|
#endif
|
2005-06-22 14:03:04 +00:00
|
|
|
|
#if CONFIG_HWCODEC == MASNONE
|
|
|
|
|
#include "pcm_playback.h"
|
|
|
|
|
#endif
|
2002-07-15 11:23:24 +00:00
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------*/
|
|
|
|
|
/* SPECIAL DEBUG STUFF */
|
|
|
|
|
/*---------------------------------------------------*/
|
2005-05-06 21:55:34 +00:00
|
|
|
|
extern char ata_device;
|
2002-07-15 11:23:24 +00:00
|
|
|
|
extern int ata_io_address;
|
2002-07-15 22:25:45 +00:00
|
|
|
|
extern int num_threads;
|
2004-08-03 20:52:31 +00:00
|
|
|
|
extern const char *thread_name[];
|
2002-07-15 22:25:45 +00:00
|
|
|
|
|
2002-08-08 20:44:25 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-07-15 22:25:45 +00:00
|
|
|
|
/* Test code!!! */
|
2002-09-24 17:22:12 +00:00
|
|
|
|
bool dbg_os(void)
|
2002-07-15 22:25:45 +00:00
|
|
|
|
{
|
|
|
|
|
char buf[32];
|
|
|
|
|
int button;
|
|
|
|
|
int i;
|
|
|
|
|
int usage;
|
|
|
|
|
|
2002-08-20 22:13:20 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
lcd_setmargins(0, 0);
|
|
|
|
|
#endif
|
2002-07-15 22:25:45 +00:00
|
|
|
|
lcd_clear_display();
|
|
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
2002-08-10 08:52:11 +00:00
|
|
|
|
lcd_puts(0, 0, "Stack usage:");
|
2002-07-15 22:25:45 +00:00
|
|
|
|
for(i = 0; i < num_threads;i++)
|
|
|
|
|
{
|
|
|
|
|
usage = thread_stack_usage(i);
|
2002-08-10 08:52:11 +00:00
|
|
|
|
snprintf(buf, 32, "%s: %d%%", thread_name[i], usage);
|
|
|
|
|
lcd_puts(0, 1+i, buf);
|
2002-07-15 22:25:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lcd_update();
|
|
|
|
|
|
2002-12-03 14:18:51 +00:00
|
|
|
|
button = button_get_w_tmo(HZ/10);
|
2002-07-15 22:25:45 +00:00
|
|
|
|
|
|
|
|
|
switch(button)
|
|
|
|
|
{
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_CANCEL:
|
2002-09-24 17:22:12 +00:00
|
|
|
|
return false;
|
2002-07-15 22:25:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-09-24 17:22:12 +00:00
|
|
|
|
return false;
|
2002-07-15 22:25:45 +00:00
|
|
|
|
}
|
|
|
|
|
#else
|
2002-09-24 17:22:12 +00:00
|
|
|
|
bool dbg_os(void)
|
2002-07-15 22:25:45 +00:00
|
|
|
|
{
|
|
|
|
|
char buf[32];
|
|
|
|
|
int button;
|
|
|
|
|
int usage;
|
|
|
|
|
int currval = 0;
|
|
|
|
|
|
2002-08-20 22:13:20 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
lcd_setmargins(0, 0);
|
|
|
|
|
#endif
|
2002-07-15 22:25:45 +00:00
|
|
|
|
lcd_clear_display();
|
|
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
2002-08-10 08:52:11 +00:00
|
|
|
|
lcd_puts(0, 0, "Stack usage");
|
2002-07-15 22:25:45 +00:00
|
|
|
|
|
2002-08-10 08:52:11 +00:00
|
|
|
|
usage = thread_stack_usage(currval);
|
|
|
|
|
snprintf(buf, 32, "%d: %d%% ", currval, usage);
|
|
|
|
|
lcd_puts(0, 1, buf);
|
2004-08-30 19:52:45 +00:00
|
|
|
|
|
2002-12-03 14:18:51 +00:00
|
|
|
|
button = button_get_w_tmo(HZ/10);
|
2002-07-15 22:25:45 +00:00
|
|
|
|
|
|
|
|
|
switch(button)
|
|
|
|
|
{
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_CANCEL:
|
2002-09-24 17:22:12 +00:00
|
|
|
|
return false;
|
2002-07-15 22:25:45 +00:00
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_DEC:
|
2002-08-10 08:52:11 +00:00
|
|
|
|
currval--;
|
|
|
|
|
if(currval < 0)
|
|
|
|
|
currval = num_threads-1;
|
|
|
|
|
break;
|
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_INC:
|
2002-08-10 08:52:11 +00:00
|
|
|
|
currval++;
|
|
|
|
|
if(currval > num_threads-1)
|
|
|
|
|
currval = 0;
|
|
|
|
|
break;
|
2002-07-15 22:25:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-09-24 17:22:12 +00:00
|
|
|
|
return false;
|
2002-07-15 22:25:45 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
2002-07-15 11:23:24 +00:00
|
|
|
|
|
2005-06-22 14:03:04 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
#if CONFIG_HWCODEC != MASNONE
|
2005-04-04 12:06:29 +00:00
|
|
|
|
bool dbg_audio_thread(void)
|
2002-10-14 14:13:48 +00:00
|
|
|
|
{
|
|
|
|
|
char buf[32];
|
|
|
|
|
int button;
|
2005-04-04 12:06:29 +00:00
|
|
|
|
struct audio_debug d;
|
2002-10-14 14:13:48 +00:00
|
|
|
|
|
2002-10-15 07:23:18 +00:00
|
|
|
|
lcd_setmargins(0, 0);
|
2005-06-22 21:37:00 +00:00
|
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
2002-10-15 07:23:18 +00:00
|
|
|
|
|
2002-10-14 14:13:48 +00:00
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
button = button_get_w_tmo(HZ/5);
|
|
|
|
|
switch(button)
|
|
|
|
|
{
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_CANCEL:
|
2002-10-14 14:13:48 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-04 12:06:29 +00:00
|
|
|
|
audio_get_debugdata(&d);
|
2002-10-14 14:13:48 +00:00
|
|
|
|
|
|
|
|
|
lcd_clear_display();
|
|
|
|
|
|
2005-04-05 11:33:58 +00:00
|
|
|
|
snprintf(buf, sizeof(buf), "read: %x", d.audiobuf_read);
|
2002-10-14 14:13:48 +00:00
|
|
|
|
lcd_puts(0, 0, buf);
|
2005-04-05 11:33:58 +00:00
|
|
|
|
snprintf(buf, sizeof(buf), "write: %x", d.audiobuf_write);
|
2002-10-14 14:13:48 +00:00
|
|
|
|
lcd_puts(0, 1, buf);
|
2005-04-05 11:33:58 +00:00
|
|
|
|
snprintf(buf, sizeof(buf), "swap: %x", d.audiobuf_swapwrite);
|
2002-10-14 14:13:48 +00:00
|
|
|
|
lcd_puts(0, 2, buf);
|
|
|
|
|
snprintf(buf, sizeof(buf), "playing: %d", d.playing);
|
|
|
|
|
lcd_puts(0, 3, buf);
|
2002-12-05 14:11:48 +00:00
|
|
|
|
snprintf(buf, sizeof(buf), "playable: %x", d.playable_space);
|
2002-10-14 14:13:48 +00:00
|
|
|
|
lcd_puts(0, 4, buf);
|
|
|
|
|
snprintf(buf, sizeof(buf), "unswapped: %x", d.unswapped_space);
|
|
|
|
|
lcd_puts(0, 5, buf);
|
2002-10-15 07:23:18 +00:00
|
|
|
|
|
2004-07-08 13:14:44 +00:00
|
|
|
|
/* Playable space left */
|
2005-04-05 11:33:58 +00:00
|
|
|
|
scrollbar(0, 6*8, 112, 4, d.audiobuflen, 0,
|
2004-07-08 13:14:44 +00:00
|
|
|
|
d.playable_space, HORIZONTAL);
|
2002-10-15 07:23:18 +00:00
|
|
|
|
|
2004-07-08 13:14:44 +00:00
|
|
|
|
/* Show the watermark limit */
|
2005-04-05 11:33:58 +00:00
|
|
|
|
scrollbar(0, 6*8+4, 112, 4, d.audiobuflen, 0,
|
2004-07-08 13:14:44 +00:00
|
|
|
|
d.low_watermark_level, HORIZONTAL);
|
2002-10-15 07:23:18 +00:00
|
|
|
|
|
2002-12-05 13:09:51 +00:00
|
|
|
|
snprintf(buf, sizeof(buf), "wm: %x - %x",
|
|
|
|
|
d.low_watermark_level, d.lowest_watermark_level);
|
2002-10-15 07:23:18 +00:00
|
|
|
|
lcd_puts(0, 7, buf);
|
2002-10-14 14:13:48 +00:00
|
|
|
|
|
|
|
|
|
lcd_update();
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2005-06-22 14:03:04 +00:00
|
|
|
|
#else
|
|
|
|
|
extern size_t audiobuffer_free;
|
|
|
|
|
extern int codecbuflen;
|
|
|
|
|
extern int codecbufused;
|
2005-06-22 20:37:31 +00:00
|
|
|
|
extern int track_count;
|
2005-06-22 14:03:04 +00:00
|
|
|
|
|
|
|
|
|
static int ticks, boost_ticks;
|
|
|
|
|
|
|
|
|
|
void dbg_audio_task(void)
|
|
|
|
|
{
|
|
|
|
|
if(FREQ > CPUFREQ_NORMAL)
|
|
|
|
|
boost_ticks++;
|
|
|
|
|
|
|
|
|
|
ticks++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool dbg_audio_thread(void)
|
|
|
|
|
{
|
|
|
|
|
char buf[32];
|
|
|
|
|
int button;
|
|
|
|
|
int line;
|
2005-06-22 21:30:34 +00:00
|
|
|
|
int center, height;
|
2005-06-22 14:09:07 +00:00
|
|
|
|
bool done = false;
|
2005-06-22 21:30:34 +00:00
|
|
|
|
lcd_getstringsize(" ", ¢er, &height);
|
|
|
|
|
center = (height/2)-3;
|
2005-06-22 14:03:04 +00:00
|
|
|
|
|
|
|
|
|
ticks = boost_ticks = 0;
|
|
|
|
|
|
|
|
|
|
tick_add_task(dbg_audio_task);
|
|
|
|
|
|
|
|
|
|
lcd_setmargins(0, 0);
|
2005-06-22 21:37:00 +00:00
|
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
2005-06-22 14:03:04 +00:00
|
|
|
|
|
2005-06-22 14:09:07 +00:00
|
|
|
|
while(!done)
|
2005-06-22 14:03:04 +00:00
|
|
|
|
{
|
|
|
|
|
button = button_get_w_tmo(HZ/5);
|
|
|
|
|
switch(button)
|
|
|
|
|
{
|
|
|
|
|
case SETTINGS_CANCEL:
|
2005-06-22 14:09:07 +00:00
|
|
|
|
done = true;
|
|
|
|
|
break;
|
2005-06-22 14:03:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
line = 0;
|
|
|
|
|
|
|
|
|
|
lcd_clear_display();
|
|
|
|
|
|
2005-06-22 20:37:31 +00:00
|
|
|
|
snprintf(buf, sizeof(buf), "pcm: %d/%d",
|
2005-06-22 14:03:04 +00:00
|
|
|
|
PCMBUF_SIZE-(int)audiobuffer_free, PCMBUF_SIZE);
|
|
|
|
|
lcd_puts(0, line++, buf);
|
|
|
|
|
|
|
|
|
|
/* Playable space left */
|
2005-06-22 21:30:34 +00:00
|
|
|
|
scrollbar(0, line*height + center, LCD_WIDTH, 6, PCMBUF_SIZE, 0,
|
2005-06-22 14:03:04 +00:00
|
|
|
|
PCMBUF_SIZE-audiobuffer_free, HORIZONTAL);
|
|
|
|
|
line++;
|
2002-10-14 14:13:48 +00:00
|
|
|
|
|
2005-06-22 20:37:31 +00:00
|
|
|
|
snprintf(buf, sizeof(buf), "codec: %d/%d", codecbufused, codecbuflen);
|
2005-06-22 14:03:04 +00:00
|
|
|
|
lcd_puts(0, line++, buf);
|
|
|
|
|
|
|
|
|
|
/* Playable space left */
|
2005-06-22 21:30:34 +00:00
|
|
|
|
scrollbar(0, line*height + center, LCD_WIDTH, 6, codecbuflen, 0,
|
2005-06-22 14:03:04 +00:00
|
|
|
|
codecbufused, HORIZONTAL);
|
|
|
|
|
line++;
|
|
|
|
|
|
2005-06-22 20:37:31 +00:00
|
|
|
|
snprintf(buf, sizeof(buf), "track count: %d", track_count);
|
|
|
|
|
lcd_puts(0, line++, buf);
|
|
|
|
|
|
2005-06-22 14:03:04 +00:00
|
|
|
|
snprintf(buf, sizeof(buf), "cpu freq: %dMHz", (int)FREQ/1000000+1);
|
|
|
|
|
lcd_puts(0, line++, buf);
|
|
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "boost ratio: %d%%",
|
|
|
|
|
boost_ticks * 100 / ticks);
|
|
|
|
|
lcd_puts(0, line++, buf);
|
|
|
|
|
|
|
|
|
|
lcd_update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tick_remove_task(dbg_audio_task);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
2003-08-01 08:00:54 +00:00
|
|
|
|
|
|
|
|
|
/* Tool function to calculate a CRC16 across some buffer */
|
2004-08-18 01:09:31 +00:00
|
|
|
|
unsigned short crc_16(const unsigned char* buf, unsigned len)
|
2003-08-01 08:00:54 +00:00
|
|
|
|
{
|
2003-08-02 12:53:57 +00:00
|
|
|
|
/* CCITT standard polynomial 0x1021 */
|
2003-08-01 08:00:54 +00:00
|
|
|
|
static const unsigned short crc16_lookup[16] =
|
|
|
|
|
{ /* lookup table for 4 bits at a time is affordable */
|
|
|
|
|
0x0000, 0x1021, 0x2042, 0x3063,
|
|
|
|
|
0x4084, 0x50A5, 0x60C6, 0x70E7,
|
|
|
|
|
0x8108, 0x9129, 0xA14A, 0xB16B,
|
|
|
|
|
0xC18C, 0xD1AD, 0xE1CE, 0xF1EF
|
|
|
|
|
};
|
|
|
|
|
unsigned short crc16 = 0xFFFF; /* initialise to 0xFFFF (CCITT specification) */
|
|
|
|
|
unsigned t;
|
|
|
|
|
unsigned char byte;
|
|
|
|
|
|
|
|
|
|
while (len--)
|
|
|
|
|
{
|
|
|
|
|
byte = *buf++; /* get one byte of data */
|
|
|
|
|
|
|
|
|
|
/* upper nibble of our data */
|
|
|
|
|
t = crc16 >> 12; /* extract the 4 most significant bits */
|
|
|
|
|
t ^= byte >> 4; /* XOR in 4 bits of the data into the extracted bits */
|
|
|
|
|
crc16 <<= 4; /* shift the CRC Register left 4 bits */
|
|
|
|
|
crc16 ^= crc16_lookup[t]; /* do the table lookup and XOR the result */
|
|
|
|
|
|
|
|
|
|
/* lower nibble of our data */
|
|
|
|
|
t = crc16 >> 12; /* extract the 4 most significant bits */
|
|
|
|
|
t ^= byte & 0x0F; /* XOR in 4 bits of the data into the extracted bits */
|
|
|
|
|
crc16 <<= 4; /* shift the CRC Register left 4 bits */
|
|
|
|
|
crc16 ^= crc16_lookup[t]; /* do the table lookup and XOR the result */
|
|
|
|
|
}
|
2004-09-28 06:23:57 +00:00
|
|
|
|
|
2003-08-01 08:00:54 +00:00
|
|
|
|
return crc16;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-02-08 15:12:25 +00:00
|
|
|
|
#if CONFIG_CPU == TCC730
|
|
|
|
|
static unsigned flash_word_temp __attribute__ ((section (".idata")));
|
|
|
|
|
|
|
|
|
|
static void flash_write_word(unsigned addr, unsigned value) __attribute__ ((section(".icode")));
|
|
|
|
|
static void flash_write_word(unsigned addr, unsigned value) {
|
|
|
|
|
flash_word_temp = value;
|
|
|
|
|
|
|
|
|
|
long extAddr = (long)addr << 1;
|
2005-02-25 09:19:44 +00:00
|
|
|
|
ddma_transfer(1, 1, &flash_word_temp, extAddr, 2);
|
2005-02-08 15:12:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static unsigned flash_read_word(unsigned addr) __attribute__ ((section(".icode")));
|
|
|
|
|
static unsigned flash_read_word(unsigned addr) {
|
|
|
|
|
long extAddr = (long)addr << 1;
|
2005-02-25 09:19:44 +00:00
|
|
|
|
ddma_transfer(1, 1, &flash_word_temp, extAddr, 2);
|
2005-02-08 15:12:25 +00:00
|
|
|
|
return flash_word_temp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-08-01 08:00:54 +00:00
|
|
|
|
|
2003-05-17 20:40:30 +00:00
|
|
|
|
/* Tool function to read the flash manufacturer and type, if available.
|
|
|
|
|
Only chips which could be reprogrammed in system will return values.
|
|
|
|
|
(The mode switch addresses vary between flash manufacturers, hence addr1/2) */
|
2004-07-19 21:21:34 +00:00
|
|
|
|
/* In IRAM to avoid problems when running directly from Flash */
|
2005-06-18 01:25:47 +00:00
|
|
|
|
bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device,
|
2004-07-19 21:21:34 +00:00
|
|
|
|
unsigned addr1, unsigned addr2)
|
|
|
|
|
__attribute__ ((section (".icode")));
|
|
|
|
|
bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device,
|
|
|
|
|
unsigned addr1, unsigned addr2)
|
|
|
|
|
|
2003-05-17 20:40:30 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned not_manu, not_id; /* read values before switching to ID mode */
|
|
|
|
|
unsigned manu, id; /* read values when in ID mode */
|
2005-02-08 15:12:25 +00:00
|
|
|
|
#if CONFIG_CPU == TCC730
|
|
|
|
|
#define FLASH(addr) (flash_read_word(addr))
|
|
|
|
|
#define SET_FLASH(addr, val) (flash_write_word((addr), (val)))
|
|
|
|
|
#else
|
2003-05-17 20:40:30 +00:00
|
|
|
|
volatile unsigned char* flash = (unsigned char*)0x2000000; /* flash mapping */
|
2005-02-08 15:12:25 +00:00
|
|
|
|
#define FLASH(addr) (flash[addr])
|
|
|
|
|
#define SET_FLASH(addr, val) (flash[addr] = val)
|
|
|
|
|
|
|
|
|
|
#endif
|
2004-07-19 21:21:34 +00:00
|
|
|
|
int old_level; /* saved interrupt level */
|
2003-05-17 20:40:30 +00:00
|
|
|
|
|
2005-02-08 15:12:25 +00:00
|
|
|
|
not_manu = FLASH(0); /* read the normal content */
|
|
|
|
|
not_id = FLASH(1); /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
|
2003-05-17 20:40:30 +00:00
|
|
|
|
|
2004-07-19 21:21:34 +00:00
|
|
|
|
/* disable interrupts, prevent any stray flash access */
|
|
|
|
|
old_level = set_irq_level(HIGHEST_IRQ_LEVEL);
|
|
|
|
|
|
2005-02-08 15:12:25 +00:00
|
|
|
|
SET_FLASH(addr1, 0xAA); /* enter command mode */
|
|
|
|
|
SET_FLASH(addr2, 0x55);
|
|
|
|
|
SET_FLASH(addr1, 0x90); /* ID command */
|
2004-07-19 21:21:34 +00:00
|
|
|
|
/* Atmel wants 20ms pause here */
|
|
|
|
|
/* sleep(HZ/50); no sleeping possible while interrupts are disabled */
|
2003-05-17 20:40:30 +00:00
|
|
|
|
|
2005-02-08 15:12:25 +00:00
|
|
|
|
manu = FLASH(0); /* read the IDs */
|
|
|
|
|
id = FLASH(1);
|
2003-05-17 20:40:30 +00:00
|
|
|
|
|
2005-02-08 15:12:25 +00:00
|
|
|
|
SET_FLASH(0, 0xF0); /* reset flash (back to normal read mode) */
|
2004-07-19 21:21:34 +00:00
|
|
|
|
/* Atmel wants 20ms pause here */
|
|
|
|
|
/* sleep(HZ/50); no sleeping possible while interrupts are disabled */
|
|
|
|
|
|
|
|
|
|
set_irq_level(old_level); /* enable interrupts again */
|
2003-05-17 20:40:30 +00:00
|
|
|
|
|
|
|
|
|
/* I assume success if the obtained values are different from
|
|
|
|
|
the normal flash content. This is not perfectly bulletproof, they
|
|
|
|
|
could theoretically be the same by chance, causing us to fail. */
|
|
|
|
|
if (not_manu != manu || not_id != id) /* a value has changed */
|
|
|
|
|
{
|
|
|
|
|
*p_manufacturer = manu; /* return the results */
|
|
|
|
|
*p_device = id;
|
|
|
|
|
return true; /* success */
|
|
|
|
|
}
|
|
|
|
|
return false; /* fail */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-10-08 10:52:46 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
bool dbg_hw_info(void)
|
|
|
|
|
{
|
2005-02-02 21:57:40 +00:00
|
|
|
|
#if CONFIG_CPU == SH7034
|
2002-10-08 10:52:46 +00:00
|
|
|
|
char buf[32];
|
|
|
|
|
int button;
|
|
|
|
|
int usb_polarity;
|
2002-10-08 12:08:30 +00:00
|
|
|
|
int pr_polarity;
|
2002-10-08 11:15:00 +00:00
|
|
|
|
int bitmask = *(unsigned short*)0x20000fc;
|
2002-10-08 10:52:46 +00:00
|
|
|
|
int rom_version = *(unsigned short*)0x20000fe;
|
2003-05-17 20:40:30 +00:00
|
|
|
|
unsigned manu, id; /* flash IDs */
|
|
|
|
|
bool got_id; /* flag if we managed to get the flash IDs */
|
2003-10-29 22:10:13 +00:00
|
|
|
|
unsigned rom_crc = 0xFFFF; /* CRC16 of the boot ROM */
|
|
|
|
|
bool has_bootrom; /* flag for boot ROM present */
|
2004-08-30 19:52:45 +00:00
|
|
|
|
int oldmode; /* saved memory guard mode */
|
2002-10-08 10:52:46 +00:00
|
|
|
|
|
2004-10-01 20:21:17 +00:00
|
|
|
|
#ifdef USB_ENABLE_ONDIOSTYLE
|
2005-05-08 12:16:46 +00:00
|
|
|
|
if(PADRL & 0x20)
|
2004-10-01 20:21:17 +00:00
|
|
|
|
#else
|
2005-05-08 12:16:46 +00:00
|
|
|
|
if(PADRH & 0x04)
|
2004-10-01 20:21:17 +00:00
|
|
|
|
#endif
|
2002-10-08 12:08:30 +00:00
|
|
|
|
usb_polarity = 0; /* Negative */
|
2002-10-08 10:52:46 +00:00
|
|
|
|
else
|
2002-10-08 12:08:30 +00:00
|
|
|
|
usb_polarity = 1; /* Positive */
|
2002-10-08 10:52:46 +00:00
|
|
|
|
|
2005-05-08 12:16:46 +00:00
|
|
|
|
if(PADRH & 0x08)
|
2002-10-08 12:08:30 +00:00
|
|
|
|
pr_polarity = 0; /* Negative */
|
|
|
|
|
else
|
|
|
|
|
pr_polarity = 1; /* Positive */
|
2002-10-09 06:36:32 +00:00
|
|
|
|
|
2004-08-30 19:52:45 +00:00
|
|
|
|
oldmode = system_memory_guard(MEMGUARD_NONE); /* disable memory guard */
|
|
|
|
|
|
2003-05-17 20:40:30 +00:00
|
|
|
|
/* get flash ROM type */
|
|
|
|
|
got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
|
|
|
|
|
if (!got_id)
|
|
|
|
|
got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */
|
|
|
|
|
|
2003-10-29 22:10:13 +00:00
|
|
|
|
/* check if the boot ROM area is a flash mirror */
|
|
|
|
|
has_bootrom = (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
|
|
|
|
|
if (has_bootrom) /* if ROM and Flash different */
|
|
|
|
|
{
|
|
|
|
|
/* calculate CRC16 checksum of boot ROM */
|
|
|
|
|
rom_crc = crc_16((unsigned char*)0x0000, 64*1024);
|
|
|
|
|
}
|
2003-08-01 08:00:54 +00:00
|
|
|
|
|
2004-08-30 19:52:45 +00:00
|
|
|
|
system_memory_guard(oldmode); /* re-enable memory guard */
|
|
|
|
|
|
2002-10-08 10:52:46 +00:00
|
|
|
|
lcd_setmargins(0, 0);
|
|
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
|
|
|
|
lcd_clear_display();
|
|
|
|
|
|
2002-10-08 12:08:30 +00:00
|
|
|
|
lcd_puts(0, 0, "[Hardware info]");
|
|
|
|
|
|
2002-10-08 10:52:46 +00:00
|
|
|
|
snprintf(buf, 32, "ROM: %d.%02d", rom_version/100, rom_version%100);
|
|
|
|
|
lcd_puts(0, 1, buf);
|
|
|
|
|
|
2002-10-08 12:08:30 +00:00
|
|
|
|
snprintf(buf, 32, "Mask: 0x%04x", bitmask);
|
2002-10-08 10:52:46 +00:00
|
|
|
|
lcd_puts(0, 2, buf);
|
|
|
|
|
|
2002-10-08 12:08:30 +00:00
|
|
|
|
snprintf(buf, 32, "USB: %s", usb_polarity?"positive":"negative");
|
2002-10-08 10:52:46 +00:00
|
|
|
|
lcd_puts(0, 3, buf);
|
|
|
|
|
|
2002-10-08 12:08:30 +00:00
|
|
|
|
snprintf(buf, 32, "PR: %s", pr_polarity?"positive":"negative");
|
2004-10-22 20:44:26 +00:00
|
|
|
|
lcd_puts(0, 4, buf);
|
2002-10-08 12:08:30 +00:00
|
|
|
|
|
2003-05-17 20:40:30 +00:00
|
|
|
|
if (got_id)
|
|
|
|
|
snprintf(buf, 32, "Flash: M=%02x D=%02x", manu, id);
|
|
|
|
|
else
|
|
|
|
|
snprintf(buf, 32, "Flash: M=?? D=??"); /* unknown, sorry */
|
2004-10-22 20:44:26 +00:00
|
|
|
|
lcd_puts(0, 5, buf);
|
2003-08-01 08:00:54 +00:00
|
|
|
|
|
2003-10-29 22:10:13 +00:00
|
|
|
|
if (has_bootrom)
|
|
|
|
|
{
|
|
|
|
|
snprintf(buf, 32-3, "ROM CRC: 0x%04x", rom_crc);
|
|
|
|
|
if (rom_crc == 0x222F) /* known Version 1 */
|
|
|
|
|
strcat(buf, " V1");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
snprintf(buf, 32, "Boot ROM: none");
|
|
|
|
|
}
|
2004-10-22 20:44:26 +00:00
|
|
|
|
lcd_puts(0, 6, buf);
|
|
|
|
|
|
|
|
|
|
#ifndef HAVE_MMC /* have ATA */
|
|
|
|
|
snprintf(buf, 32, "ATA: 0x%x,%s", ata_io_address,
|
|
|
|
|
ata_device ? "slave":"master");
|
2003-08-01 08:00:54 +00:00
|
|
|
|
lcd_puts(0, 7, buf);
|
2004-10-22 20:44:26 +00:00
|
|
|
|
#endif
|
2002-10-08 10:52:46 +00:00
|
|
|
|
lcd_update();
|
2002-10-14 14:25:25 +00:00
|
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
button = button_get(true);
|
2004-09-19 21:58:37 +00:00
|
|
|
|
if(button == SETTINGS_CANCEL)
|
2002-10-14 14:25:25 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2005-02-02 21:57:40 +00:00
|
|
|
|
#endif /* CONFIG_CPU == SH7034 */
|
2002-10-08 10:52:46 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2002-10-08 12:08:30 +00:00
|
|
|
|
#else
|
|
|
|
|
bool dbg_hw_info(void)
|
|
|
|
|
{
|
|
|
|
|
char buf[32];
|
|
|
|
|
int button;
|
|
|
|
|
int currval = 0;
|
|
|
|
|
int usb_polarity;
|
|
|
|
|
int bitmask = *(unsigned short*)0x20000fc;
|
|
|
|
|
int rom_version = *(unsigned short*)0x20000fe;
|
2003-05-20 21:30:53 +00:00
|
|
|
|
unsigned manu, id; /* flash IDs */
|
|
|
|
|
bool got_id; /* flag if we managed to get the flash IDs */
|
2003-10-29 22:10:13 +00:00
|
|
|
|
unsigned rom_crc = 0xFFFF; /* CRC16 of the boot ROM */
|
|
|
|
|
bool has_bootrom; /* flag for boot ROM present */
|
2004-08-30 19:52:45 +00:00
|
|
|
|
int oldmode; /* saved memory guard mode */
|
2002-10-08 12:08:30 +00:00
|
|
|
|
|
2005-05-08 12:16:46 +00:00
|
|
|
|
if(PADRH & 0x04)
|
2002-10-08 12:08:30 +00:00
|
|
|
|
usb_polarity = 0; /* Negative */
|
|
|
|
|
else
|
|
|
|
|
usb_polarity = 1; /* Positive */
|
|
|
|
|
|
2004-08-30 19:52:45 +00:00
|
|
|
|
oldmode = system_memory_guard(MEMGUARD_NONE); /* disable memory guard */
|
|
|
|
|
|
2003-05-20 21:30:53 +00:00
|
|
|
|
/* get flash ROM type */
|
|
|
|
|
got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
|
|
|
|
|
if (!got_id)
|
|
|
|
|
got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */
|
|
|
|
|
|
2003-10-29 22:10:13 +00:00
|
|
|
|
/* check if the boot ROM area is a flash mirror */
|
|
|
|
|
has_bootrom = (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
|
|
|
|
|
if (has_bootrom) /* if ROM and Flash different */
|
|
|
|
|
{
|
|
|
|
|
/* calculate CRC16 checksum of boot ROM */
|
|
|
|
|
rom_crc = crc_16((unsigned char*)0x0000, 64*1024);
|
|
|
|
|
}
|
2004-08-30 19:52:45 +00:00
|
|
|
|
|
|
|
|
|
system_memory_guard(oldmode); /* re-enable memory guard */
|
2003-08-01 08:00:54 +00:00
|
|
|
|
|
2002-10-08 12:08:30 +00:00
|
|
|
|
lcd_clear_display();
|
|
|
|
|
|
|
|
|
|
lcd_puts(0, 0, "[HW Info]");
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
switch(currval)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
snprintf(buf, 32, "ROM: %d.%02d",
|
|
|
|
|
rom_version/100, rom_version%100);
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
snprintf(buf, 32, "USB: %s",
|
|
|
|
|
usb_polarity?"pos":"neg");
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2003-08-05 13:39:38 +00:00
|
|
|
|
snprintf(buf, 32, "ATA: 0x%x%s",
|
2003-08-05 13:41:00 +00:00
|
|
|
|
ata_io_address, ata_device ? "s":"m");
|
2002-10-08 12:08:30 +00:00
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
snprintf(buf, 32, "Mask: %04x", bitmask);
|
|
|
|
|
break;
|
2003-05-20 21:30:53 +00:00
|
|
|
|
case 4:
|
|
|
|
|
if (got_id)
|
|
|
|
|
snprintf(buf, 32, "Flash:%02x,%02x", manu, id);
|
|
|
|
|
else
|
|
|
|
|
snprintf(buf, 32, "Flash:??,??"); /* unknown, sorry */
|
|
|
|
|
break;
|
2003-08-01 08:00:54 +00:00
|
|
|
|
case 5:
|
2003-10-29 22:10:13 +00:00
|
|
|
|
if (has_bootrom)
|
|
|
|
|
snprintf(buf, 32, "RomCRC:%04x", rom_crc);
|
|
|
|
|
else
|
|
|
|
|
snprintf(buf, 32, "BootROM: no");
|
2002-10-08 12:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-10-09 06:36:32 +00:00
|
|
|
|
lcd_puts(0, 1, buf);
|
2002-10-08 12:08:30 +00:00
|
|
|
|
lcd_update();
|
|
|
|
|
|
|
|
|
|
button = button_get(true);
|
|
|
|
|
|
|
|
|
|
switch(button)
|
|
|
|
|
{
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_CANCEL:
|
2002-10-08 12:08:30 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_DEC:
|
2002-10-08 12:08:30 +00:00
|
|
|
|
currval--;
|
|
|
|
|
if(currval < 0)
|
2003-08-01 08:00:54 +00:00
|
|
|
|
currval = 5;
|
2002-10-08 12:08:30 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_INC:
|
2002-10-08 12:08:30 +00:00
|
|
|
|
currval++;
|
2003-08-01 08:00:54 +00:00
|
|
|
|
if(currval > 5)
|
2002-10-08 12:08:30 +00:00
|
|
|
|
currval = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2002-10-08 10:52:46 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2002-10-10 12:01:58 +00:00
|
|
|
|
bool dbg_partitions(void)
|
|
|
|
|
{
|
|
|
|
|
int partition=0;
|
|
|
|
|
|
|
|
|
|
lcd_clear_display();
|
|
|
|
|
lcd_puts(0, 0, "Partition");
|
|
|
|
|
lcd_puts(0, 1, "list");
|
|
|
|
|
lcd_update();
|
2002-12-03 14:18:51 +00:00
|
|
|
|
sleep(HZ/2);
|
2002-10-10 12:01:58 +00:00
|
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
char buf[32];
|
|
|
|
|
int button;
|
|
|
|
|
struct partinfo* p = disk_partinfo(partition);
|
|
|
|
|
|
|
|
|
|
lcd_clear_display();
|
2005-01-24 01:39:24 +00:00
|
|
|
|
snprintf(buf, sizeof buf, "P%d: S:%lx", partition, p->start);
|
2002-10-10 12:01:58 +00:00
|
|
|
|
lcd_puts(0, 0, buf);
|
2005-01-24 01:39:24 +00:00
|
|
|
|
snprintf(buf, sizeof buf, "T:%x %ld MB", p->type, p->size / 2048);
|
2002-10-10 12:01:58 +00:00
|
|
|
|
lcd_puts(0, 1, buf);
|
|
|
|
|
lcd_update();
|
|
|
|
|
|
|
|
|
|
button = button_get(true);
|
|
|
|
|
|
|
|
|
|
switch(button)
|
|
|
|
|
{
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_OK:
|
|
|
|
|
case SETTINGS_CANCEL:
|
2002-10-10 12:01:58 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_DEC:
|
2002-10-10 12:01:58 +00:00
|
|
|
|
partition--;
|
|
|
|
|
if (partition < 0)
|
|
|
|
|
partition = 3;
|
|
|
|
|
break;
|
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_INC:
|
2002-10-10 12:01:58 +00:00
|
|
|
|
partition++;
|
|
|
|
|
if (partition > 3)
|
|
|
|
|
partition = 0;
|
|
|
|
|
break;
|
2004-07-26 16:06:59 +00:00
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
if(default_event_handler(button) == SYS_USB_CONNECTED)
|
|
|
|
|
return true;
|
|
|
|
|
break;
|
2002-10-10 12:01:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-08 20:44:25 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-07-15 11:23:24 +00:00
|
|
|
|
/* Test code!!! */
|
2002-09-24 17:22:12 +00:00
|
|
|
|
bool dbg_ports(void)
|
2002-07-15 11:23:24 +00:00
|
|
|
|
{
|
2005-02-02 21:57:40 +00:00
|
|
|
|
#if CONFIG_CPU == SH7034
|
2002-07-15 11:23:24 +00:00
|
|
|
|
unsigned short porta;
|
|
|
|
|
unsigned short portb;
|
|
|
|
|
unsigned char portc;
|
|
|
|
|
char buf[32];
|
|
|
|
|
int button;
|
|
|
|
|
int battery_voltage;
|
|
|
|
|
int batt_int, batt_frac;
|
|
|
|
|
|
2002-08-20 22:13:20 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
lcd_setmargins(0, 0);
|
|
|
|
|
#endif
|
2002-07-15 11:23:24 +00:00
|
|
|
|
lcd_clear_display();
|
|
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
porta = PADR;
|
|
|
|
|
portb = PBDR;
|
|
|
|
|
portc = PCDR;
|
|
|
|
|
|
|
|
|
|
snprintf(buf, 32, "PADR: %04x", porta);
|
|
|
|
|
lcd_puts(0, 0, buf);
|
|
|
|
|
snprintf(buf, 32, "PBDR: %04x", portb);
|
|
|
|
|
lcd_puts(0, 1, buf);
|
|
|
|
|
|
|
|
|
|
snprintf(buf, 32, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4));
|
|
|
|
|
lcd_puts(0, 2, buf);
|
|
|
|
|
snprintf(buf, 32, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5));
|
|
|
|
|
lcd_puts(0, 3, buf);
|
|
|
|
|
snprintf(buf, 32, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6));
|
|
|
|
|
lcd_puts(0, 4, buf);
|
|
|
|
|
snprintf(buf, 32, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7));
|
|
|
|
|
lcd_puts(0, 5, buf);
|
|
|
|
|
|
2002-08-06 10:52:51 +00:00
|
|
|
|
battery_voltage = (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) / 10000;
|
2002-07-15 11:23:24 +00:00
|
|
|
|
batt_int = battery_voltage / 100;
|
|
|
|
|
batt_frac = battery_voltage % 100;
|
|
|
|
|
|
|
|
|
|
snprintf(buf, 32, "Batt: %d.%02dV %d%% ", batt_int, batt_frac,
|
|
|
|
|
battery_level());
|
|
|
|
|
lcd_puts(0, 6, buf);
|
2004-10-22 20:44:26 +00:00
|
|
|
|
#ifndef HAVE_MMC /* have ATA */
|
2002-07-15 11:23:24 +00:00
|
|
|
|
snprintf(buf, 32, "ATA: %s, 0x%x",
|
|
|
|
|
ata_device?"slave":"master", ata_io_address);
|
|
|
|
|
lcd_puts(0, 7, buf);
|
2004-10-22 20:44:26 +00:00
|
|
|
|
#endif
|
2002-07-15 11:23:24 +00:00
|
|
|
|
lcd_update();
|
2003-04-09 23:17:35 +00:00
|
|
|
|
button = button_get_w_tmo(HZ/10);
|
2002-07-15 11:23:24 +00:00
|
|
|
|
|
|
|
|
|
switch(button)
|
|
|
|
|
{
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_CANCEL:
|
2002-09-24 17:22:12 +00:00
|
|
|
|
return false;
|
2002-07-15 11:23:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2005-02-11 13:16:09 +00:00
|
|
|
|
#elif CONFIG_CPU == MCF5249
|
|
|
|
|
unsigned int gpio_out;
|
|
|
|
|
unsigned int gpio1_out;
|
|
|
|
|
unsigned int gpio_read;
|
|
|
|
|
unsigned int gpio1_read;
|
|
|
|
|
unsigned int gpio_function;
|
|
|
|
|
unsigned int gpio1_function;
|
|
|
|
|
unsigned int gpio_enable;
|
|
|
|
|
unsigned int gpio1_enable;
|
|
|
|
|
int adc_buttons, adc_remote, adc_battery;
|
2005-03-01 14:40:27 +00:00
|
|
|
|
char buf[128];
|
2005-02-11 13:16:09 +00:00
|
|
|
|
int button;
|
|
|
|
|
int line;
|
2005-04-06 23:53:19 +00:00
|
|
|
|
int battery_voltage;
|
|
|
|
|
int batt_int, batt_frac;
|
2005-02-11 13:16:09 +00:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
lcd_setmargins(0, 0);
|
|
|
|
|
#endif
|
|
|
|
|
lcd_clear_display();
|
|
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
|
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
line = 0;
|
|
|
|
|
gpio_read = GPIO_READ;
|
|
|
|
|
gpio1_read = GPIO1_READ;
|
|
|
|
|
gpio_out = GPIO_OUT;
|
|
|
|
|
gpio1_out = GPIO1_OUT;
|
|
|
|
|
gpio_function = GPIO_FUNCTION;
|
|
|
|
|
gpio1_function = GPIO1_FUNCTION;
|
|
|
|
|
gpio_enable = GPIO_ENABLE;
|
|
|
|
|
gpio1_enable = GPIO1_ENABLE;
|
|
|
|
|
|
2005-03-01 14:40:27 +00:00
|
|
|
|
snprintf(buf, sizeof(buf), "GPIO_READ: %08x", gpio_read);
|
2005-02-11 13:16:09 +00:00
|
|
|
|
lcd_puts(0, line++, buf);
|
2005-03-01 14:40:27 +00:00
|
|
|
|
snprintf(buf, sizeof(buf), "GPIO_OUT: %08x", gpio_out);
|
2005-02-11 13:16:09 +00:00
|
|
|
|
lcd_puts(0, line++, buf);
|
2005-03-01 14:40:27 +00:00
|
|
|
|
snprintf(buf, sizeof(buf), "GPIO_FUNCTION: %08x", gpio_function);
|
2005-02-11 13:16:09 +00:00
|
|
|
|
lcd_puts(0, line++, buf);
|
2005-03-01 14:40:27 +00:00
|
|
|
|
snprintf(buf, sizeof(buf), "GPIO_ENABLE: %08x", gpio_enable);
|
2005-02-11 13:16:09 +00:00
|
|
|
|
lcd_puts(0, line++, buf);
|
|
|
|
|
|
2005-03-01 14:40:27 +00:00
|
|
|
|
snprintf(buf, sizeof(buf), "GPIO1_READ: %08x", gpio1_read);
|
2005-02-11 13:16:09 +00:00
|
|
|
|
lcd_puts(0, line++, buf);
|
2005-03-01 14:40:27 +00:00
|
|
|
|
snprintf(buf, sizeof(buf), "GPIO1_OUT: %08x", gpio1_out);
|
2005-02-11 13:16:09 +00:00
|
|
|
|
lcd_puts(0, line++, buf);
|
2005-03-01 14:40:27 +00:00
|
|
|
|
snprintf(buf, sizeof(buf), "GPIO1_FUNCTION: %08x", gpio1_function);
|
2005-02-11 13:16:09 +00:00
|
|
|
|
lcd_puts(0, line++, buf);
|
2005-03-01 14:40:27 +00:00
|
|
|
|
snprintf(buf, sizeof(buf), "GPIO1_ENABLE: %08x", gpio1_enable);
|
2005-02-11 13:16:09 +00:00
|
|
|
|
lcd_puts(0, line++, buf);
|
|
|
|
|
|
|
|
|
|
adc_buttons = adc_read(ADC_BUTTONS);
|
|
|
|
|
adc_remote = adc_read(ADC_REMOTE);
|
|
|
|
|
adc_battery = adc_read(ADC_BATTERY);
|
|
|
|
|
|
2005-03-01 14:40:27 +00:00
|
|
|
|
snprintf(buf, sizeof(buf), "ADC_BUTTONS: %02x", adc_buttons);
|
2005-02-11 13:16:09 +00:00
|
|
|
|
lcd_puts(0, line++, buf);
|
2005-03-01 14:40:27 +00:00
|
|
|
|
snprintf(buf, sizeof(buf), "ADC_REMOTE: %02x", adc_remote);
|
2005-02-11 13:16:09 +00:00
|
|
|
|
lcd_puts(0, line++, buf);
|
2005-03-01 14:40:27 +00:00
|
|
|
|
snprintf(buf, sizeof(buf), "ADC_BATTERY: %02x", adc_battery);
|
2005-02-11 13:16:09 +00:00
|
|
|
|
lcd_puts(0, line++, buf);
|
|
|
|
|
|
2005-04-06 23:53:19 +00:00
|
|
|
|
battery_voltage = (adc_battery * BATTERY_SCALE_FACTOR) / 10000;
|
|
|
|
|
batt_int = battery_voltage / 100;
|
|
|
|
|
batt_frac = battery_voltage % 100;
|
|
|
|
|
|
|
|
|
|
snprintf(buf, 32, "Batt: %d.%02dV %d%% ", batt_int, batt_frac,
|
|
|
|
|
battery_level());
|
|
|
|
|
lcd_puts(0, line++, buf);
|
|
|
|
|
|
2005-02-11 13:16:09 +00:00
|
|
|
|
lcd_update();
|
|
|
|
|
button = button_get_w_tmo(HZ/10);
|
|
|
|
|
|
|
|
|
|
switch(button)
|
|
|
|
|
{
|
|
|
|
|
case SETTINGS_CANCEL:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-02 21:57:40 +00:00
|
|
|
|
#endif /* CONFIG_CPU == SH7034 */
|
2002-09-24 17:22:12 +00:00
|
|
|
|
return false;
|
2002-07-15 11:23:24 +00:00
|
|
|
|
}
|
|
|
|
|
#else
|
2002-09-24 17:22:12 +00:00
|
|
|
|
bool dbg_ports(void)
|
2002-07-15 11:23:24 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned short porta;
|
|
|
|
|
unsigned short portb;
|
|
|
|
|
unsigned char portc;
|
|
|
|
|
char buf[32];
|
|
|
|
|
int button;
|
|
|
|
|
int battery_voltage;
|
|
|
|
|
int batt_int, batt_frac;
|
|
|
|
|
int currval = 0;
|
|
|
|
|
|
2002-08-20 22:13:20 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
lcd_setmargins(0, 0);
|
|
|
|
|
#endif
|
2002-07-15 11:23:24 +00:00
|
|
|
|
lcd_clear_display();
|
|
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
porta = PADR;
|
|
|
|
|
portb = PBDR;
|
|
|
|
|
portc = PCDR;
|
|
|
|
|
|
|
|
|
|
switch(currval)
|
|
|
|
|
{
|
2002-08-10 08:52:11 +00:00
|
|
|
|
case 0:
|
|
|
|
|
snprintf(buf, 32, "PADR: %04x ", porta);
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
snprintf(buf, 32, "PBDR: %04x ", portb);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
snprintf(buf, 32, "AN0: %03x ", adc_read(0));
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
snprintf(buf, 32, "AN1: %03x ", adc_read(1));
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
snprintf(buf, 32, "AN2: %03x ", adc_read(2));
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
snprintf(buf, 32, "AN3: %03x ", adc_read(3));
|
|
|
|
|
break;
|
|
|
|
|
case 6:
|
|
|
|
|
snprintf(buf, 32, "AN4: %03x ", adc_read(4));
|
|
|
|
|
break;
|
|
|
|
|
case 7:
|
|
|
|
|
snprintf(buf, 32, "AN5: %03x ", adc_read(5));
|
|
|
|
|
break;
|
|
|
|
|
case 8:
|
|
|
|
|
snprintf(buf, 32, "AN6: %03x ", adc_read(6));
|
|
|
|
|
break;
|
|
|
|
|
case 9:
|
|
|
|
|
snprintf(buf, 32, "AN7: %03x ", adc_read(7));
|
|
|
|
|
break;
|
|
|
|
|
case 10:
|
|
|
|
|
snprintf(buf, 32, "%s, 0x%x ",
|
|
|
|
|
ata_device?"slv":"mst", ata_io_address);
|
|
|
|
|
break;
|
2002-07-15 11:23:24 +00:00
|
|
|
|
}
|
|
|
|
|
lcd_puts(0, 0, buf);
|
|
|
|
|
|
2002-08-10 08:57:47 +00:00
|
|
|
|
battery_voltage = (adc_read(ADC_UNREG_POWER) *
|
|
|
|
|
BATTERY_SCALE_FACTOR) / 10000;
|
2002-07-15 11:23:24 +00:00
|
|
|
|
batt_int = battery_voltage / 100;
|
|
|
|
|
batt_frac = battery_voltage % 100;
|
|
|
|
|
|
|
|
|
|
snprintf(buf, 32, "Batt: %d.%02dV", batt_int, batt_frac);
|
|
|
|
|
lcd_puts(0, 1, buf);
|
|
|
|
|
|
2002-12-03 14:18:51 +00:00
|
|
|
|
button = button_get_w_tmo(HZ/5);
|
2002-07-15 11:23:24 +00:00
|
|
|
|
|
|
|
|
|
switch(button)
|
|
|
|
|
{
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_CANCEL:
|
2002-09-24 17:22:12 +00:00
|
|
|
|
return false;
|
2002-08-10 08:52:11 +00:00
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_DEC:
|
2002-08-10 08:52:11 +00:00
|
|
|
|
currval--;
|
|
|
|
|
if(currval < 0)
|
2002-08-14 08:04:42 +00:00
|
|
|
|
currval = 10;
|
2002-08-10 08:52:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_INC:
|
2002-08-10 08:52:11 +00:00
|
|
|
|
currval++;
|
2002-08-14 08:04:42 +00:00
|
|
|
|
if(currval > 10)
|
2002-08-10 08:52:11 +00:00
|
|
|
|
currval = 0;
|
|
|
|
|
break;
|
2002-07-15 11:23:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-09-24 17:22:12 +00:00
|
|
|
|
return false;
|
2002-07-15 11:23:24 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-03-07 10:51:43 +00:00
|
|
|
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
|
|
|
|
extern int boost_counter;
|
|
|
|
|
bool dbg_cpufreq(void)
|
|
|
|
|
{
|
|
|
|
|
char buf[128];
|
|
|
|
|
int line;
|
|
|
|
|
int button;
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
lcd_setmargins(0, 0);
|
|
|
|
|
#endif
|
|
|
|
|
lcd_clear_display();
|
|
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
|
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
line = 0;
|
|
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "Frequency: %ld", FREQ);
|
|
|
|
|
lcd_puts(0, line++, buf);
|
|
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "boost_counter: %d", boost_counter);
|
|
|
|
|
lcd_puts(0, line++, buf);
|
|
|
|
|
|
|
|
|
|
lcd_update();
|
|
|
|
|
button = button_get_w_tmo(HZ/10);
|
|
|
|
|
|
|
|
|
|
switch(button)
|
|
|
|
|
{
|
|
|
|
|
case BUTTON_UP:
|
|
|
|
|
cpu_boost(true);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BUTTON_DOWN:
|
|
|
|
|
cpu_boost(false);
|
|
|
|
|
break;
|
2005-03-07 13:02:06 +00:00
|
|
|
|
|
|
|
|
|
#if CONFIG_KEYPAD == IRIVER_H100_PAD
|
2005-03-07 10:51:43 +00:00
|
|
|
|
case BUTTON_SELECT:
|
2005-03-07 13:02:06 +00:00
|
|
|
|
#else
|
|
|
|
|
case BUTTON_PLAY:
|
|
|
|
|
#endif
|
2005-03-07 10:51:43 +00:00
|
|
|
|
set_cpu_frequency(CPUFREQ_DEFAULT);
|
|
|
|
|
boost_counter = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SETTINGS_CANCEL:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2005-05-06 21:55:34 +00:00
|
|
|
|
|
2002-07-15 11:23:24 +00:00
|
|
|
|
#ifdef HAVE_RTC
|
|
|
|
|
/* Read RTC RAM contents and display them */
|
2002-09-24 17:22:12 +00:00
|
|
|
|
bool dbg_rtc(void)
|
2002-07-15 11:23:24 +00:00
|
|
|
|
{
|
|
|
|
|
char buf[32];
|
|
|
|
|
unsigned char addr = 0, r, c;
|
|
|
|
|
int i;
|
|
|
|
|
int button;
|
|
|
|
|
|
2002-08-20 22:13:20 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
lcd_setmargins(0, 0);
|
|
|
|
|
#endif
|
2002-07-15 11:23:24 +00:00
|
|
|
|
lcd_clear_display();
|
|
|
|
|
lcd_puts(0, 0, "RTC read:");
|
|
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
for (r = 0; r < 4; r++) {
|
|
|
|
|
snprintf(buf, 10, "0x%02x: ", addr + r*4);
|
|
|
|
|
for (c = 0; c <= 3; c++) {
|
|
|
|
|
i = rtc_read(addr + r*4 + c);
|
|
|
|
|
snprintf(buf + 6 + c*2, 3, "%02x", i);
|
|
|
|
|
}
|
|
|
|
|
lcd_puts(1, r+1, buf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lcd_update();
|
|
|
|
|
|
2002-12-03 14:18:51 +00:00
|
|
|
|
button = button_get_w_tmo(HZ/2);
|
2002-07-15 11:23:24 +00:00
|
|
|
|
|
|
|
|
|
switch(button)
|
|
|
|
|
{
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_INC:
|
|
|
|
|
if (addr < 63-16) { addr += 16; }
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SETTINGS_DEC:
|
|
|
|
|
if (addr) { addr -= 16; }
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
#ifdef BUTTON_F2
|
|
|
|
|
case BUTTON_F2:
|
|
|
|
|
/* clear the user RAM space */
|
|
|
|
|
for (c = 0; c <= 43; c++)
|
|
|
|
|
rtc_write(0x14 + c, 0);
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
case SETTINGS_OK:
|
|
|
|
|
case SETTINGS_CANCEL:
|
|
|
|
|
return false;
|
2002-07-15 11:23:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-09-24 17:22:12 +00:00
|
|
|
|
return false;
|
2002-07-15 11:23:24 +00:00
|
|
|
|
}
|
2005-05-08 12:16:46 +00:00
|
|
|
|
#endif /* HAVE_RTC */
|
2002-07-15 11:23:24 +00:00
|
|
|
|
|
2005-02-02 21:57:40 +00:00
|
|
|
|
#if CONFIG_HWCODEC != MASNONE
|
|
|
|
|
|
2002-07-23 15:14:02 +00:00
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
|
#define NUMROWS 1
|
|
|
|
|
#else
|
|
|
|
|
#define NUMROWS 4
|
|
|
|
|
#endif
|
2002-07-22 16:39:17 +00:00
|
|
|
|
/* Read MAS registers and display them */
|
2002-09-24 17:22:12 +00:00
|
|
|
|
bool dbg_mas(void)
|
2002-07-22 16:39:17 +00:00
|
|
|
|
{
|
|
|
|
|
char buf[32];
|
|
|
|
|
unsigned int addr = 0, r, i;
|
|
|
|
|
|
2002-08-20 22:13:20 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
lcd_setmargins(0, 0);
|
|
|
|
|
#endif
|
2002-07-22 16:39:17 +00:00
|
|
|
|
lcd_clear_display();
|
|
|
|
|
lcd_puts(0, 0, "MAS register read:");
|
|
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
2002-07-23 15:14:02 +00:00
|
|
|
|
for (r = 0; r < NUMROWS; r++) {
|
2002-07-22 16:39:17 +00:00
|
|
|
|
i = mas_readreg(addr + r);
|
2002-07-23 15:14:02 +00:00
|
|
|
|
snprintf(buf, 30, "%02x %08x", addr + r, i);
|
|
|
|
|
lcd_puts(0, r+1, buf);
|
2002-07-22 16:39:17 +00:00
|
|
|
|
}
|
2002-07-23 15:14:02 +00:00
|
|
|
|
|
2002-07-22 16:39:17 +00:00
|
|
|
|
lcd_update();
|
|
|
|
|
|
2002-12-03 14:18:51 +00:00
|
|
|
|
switch(button_get_w_tmo(HZ/16))
|
2002-07-22 16:39:17 +00:00
|
|
|
|
{
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_INC:
|
|
|
|
|
addr = (addr + NUMROWS) & 0xFF; /* register addrs are 8 bit */
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SETTINGS_DEC:
|
|
|
|
|
addr = (addr - NUMROWS) & 0xFF; /* register addrs are 8 bit */
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SETTINGS_OK:
|
|
|
|
|
case SETTINGS_CANCEL:
|
|
|
|
|
return false;
|
2002-07-22 16:39:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-09-24 17:22:12 +00:00
|
|
|
|
return false;
|
2002-07-22 16:39:17 +00:00
|
|
|
|
}
|
2005-02-02 21:57:40 +00:00
|
|
|
|
#endif /* CONFIG_HWCODEC != MASNONE */
|
2002-07-22 16:39:17 +00:00
|
|
|
|
|
2004-09-29 19:51:41 +00:00
|
|
|
|
#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
|
2002-09-24 17:22:12 +00:00
|
|
|
|
bool dbg_mas_codec(void)
|
2002-07-22 16:39:17 +00:00
|
|
|
|
{
|
|
|
|
|
char buf[32];
|
|
|
|
|
unsigned int addr = 0, r, i;
|
|
|
|
|
|
2002-08-20 22:13:20 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
lcd_setmargins(0, 0);
|
|
|
|
|
#endif
|
2002-07-22 16:39:17 +00:00
|
|
|
|
lcd_clear_display();
|
|
|
|
|
lcd_puts(0, 0, "MAS codec reg read:");
|
|
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
for (r = 0; r < 4; r++) {
|
|
|
|
|
i = mas_codec_readreg(addr + r);
|
|
|
|
|
snprintf(buf, 30, "0x%02x: %08x", addr + r, i);
|
|
|
|
|
lcd_puts(1, r+1, buf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lcd_update();
|
|
|
|
|
|
2002-12-03 14:18:51 +00:00
|
|
|
|
switch(button_get_w_tmo(HZ/16))
|
2002-07-22 16:39:17 +00:00
|
|
|
|
{
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_INC:
|
|
|
|
|
addr += 4;
|
|
|
|
|
break;
|
|
|
|
|
case SETTINGS_DEC:
|
|
|
|
|
if (addr) { addr -= 4; }
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SETTINGS_OK:
|
|
|
|
|
case SETTINGS_CANCEL:
|
|
|
|
|
return false;
|
2002-07-22 16:39:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-09-24 17:22:12 +00:00
|
|
|
|
return false;
|
2002-07-22 16:39:17 +00:00
|
|
|
|
}
|
2002-08-08 20:44:25 +00:00
|
|
|
|
#endif
|
2002-08-06 10:52:51 +00:00
|
|
|
|
|
2002-08-08 20:44:25 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-08-06 10:52:51 +00:00
|
|
|
|
/*
|
|
|
|
|
* view_battery() shows a automatically scaled graph of the battery voltage
|
|
|
|
|
* over time. Usable for estimating battery life / charging rate.
|
|
|
|
|
* The power_history array is updated in power_thread of powermgmt.c.
|
|
|
|
|
*/
|
|
|
|
|
|
2005-03-03 07:25:43 +00:00
|
|
|
|
#define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN)
|
2002-08-06 10:52:51 +00:00
|
|
|
|
#define BAT_YSPACE (LCD_HEIGHT - 20)
|
|
|
|
|
|
2002-09-24 17:22:12 +00:00
|
|
|
|
bool view_battery(void)
|
2002-08-06 10:52:51 +00:00
|
|
|
|
{
|
|
|
|
|
int view = 0;
|
|
|
|
|
int i, x, y;
|
2005-02-08 15:12:25 +00:00
|
|
|
|
unsigned short maxv, minv;
|
2002-08-06 10:52:51 +00:00
|
|
|
|
char buf[32];
|
|
|
|
|
|
2002-08-20 22:13:20 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
lcd_setmargins(0, 0);
|
|
|
|
|
#endif
|
2002-08-06 10:52:51 +00:00
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
switch (view) {
|
2002-08-10 08:57:47 +00:00
|
|
|
|
case 0: /* voltage history graph */
|
|
|
|
|
/* Find maximum and minimum voltage for scaling */
|
2005-03-03 07:25:43 +00:00
|
|
|
|
maxv = 0;
|
|
|
|
|
minv = 65535;
|
|
|
|
|
for (i = 0; i < BAT_LAST_VAL; i++) {
|
2002-08-10 08:57:47 +00:00
|
|
|
|
if (power_history[i] > maxv)
|
|
|
|
|
maxv = power_history[i];
|
2005-03-03 07:25:43 +00:00
|
|
|
|
if (power_history[i] && (power_history[i] < minv))
|
2002-08-10 08:57:47 +00:00
|
|
|
|
{
|
|
|
|
|
minv = power_history[i];
|
|
|
|
|
}
|
2002-08-06 10:52:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-03-03 07:25:43 +00:00
|
|
|
|
if ((minv < 1) || (minv >= 65535))
|
2002-08-10 08:57:47 +00:00
|
|
|
|
minv = 1;
|
|
|
|
|
if (maxv < 2)
|
|
|
|
|
maxv = 2;
|
2002-08-06 10:52:51 +00:00
|
|
|
|
|
2002-08-10 08:57:47 +00:00
|
|
|
|
lcd_clear_display();
|
2005-03-03 07:25:43 +00:00
|
|
|
|
snprintf(buf, 30, "Battery %d.%02d", power_history[0] / 100,
|
|
|
|
|
power_history[0] % 100);
|
|
|
|
|
lcd_puts(0, 0, buf);
|
2002-08-10 08:57:47 +00:00
|
|
|
|
snprintf(buf, 30, "scale %d.%02d-%d.%02d V",
|
|
|
|
|
minv / 100, minv % 100, maxv / 100, maxv % 100);
|
|
|
|
|
lcd_puts(0, 1, buf);
|
2002-08-06 10:52:51 +00:00
|
|
|
|
|
2002-08-10 08:57:47 +00:00
|
|
|
|
x = 0;
|
2005-03-03 07:25:43 +00:00
|
|
|
|
for (i = BAT_LAST_VAL - 1; i >= 0; i--) {
|
2002-08-10 08:57:47 +00:00
|
|
|
|
y = (power_history[i] - minv) * BAT_YSPACE / (maxv - minv);
|
|
|
|
|
lcd_clearline(x, LCD_HEIGHT-1, x, 20);
|
|
|
|
|
lcd_drawline(x, LCD_HEIGHT-1, x,
|
|
|
|
|
MIN(MAX(LCD_HEIGHT-1 - y, 20), LCD_HEIGHT-1));
|
|
|
|
|
x++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
2002-08-06 10:52:51 +00:00
|
|
|
|
|
2002-08-10 08:57:47 +00:00
|
|
|
|
case 1: /* status: */
|
|
|
|
|
lcd_clear_display();
|
|
|
|
|
lcd_puts(0, 0, "Power status:");
|
2002-08-06 10:52:51 +00:00
|
|
|
|
|
2002-08-10 08:57:47 +00:00
|
|
|
|
y = (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) / 10000;
|
|
|
|
|
snprintf(buf, 30, "Battery: %d.%02d V", y / 100, y % 100);
|
|
|
|
|
lcd_puts(0, 1, buf);
|
2004-12-01 00:33:18 +00:00
|
|
|
|
#ifdef ADC_EXT_POWER
|
2002-08-10 08:57:47 +00:00
|
|
|
|
y = (adc_read(ADC_EXT_POWER) * EXT_SCALE_FACTOR) / 10000;
|
|
|
|
|
snprintf(buf, 30, "External: %d.%02d V", y / 100, y % 100);
|
|
|
|
|
lcd_puts(0, 2, buf);
|
2004-12-01 00:33:18 +00:00
|
|
|
|
#endif
|
|
|
|
|
#ifdef HAVE_CHARGING
|
2002-08-10 08:57:47 +00:00
|
|
|
|
snprintf(buf, 30, "Charger: %s",
|
|
|
|
|
charger_inserted() ? "present" : "absent");
|
|
|
|
|
lcd_puts(0, 3, buf);
|
2005-03-03 07:25:43 +00:00
|
|
|
|
#endif
|
2002-08-06 10:52:51 +00:00
|
|
|
|
#ifdef HAVE_CHARGE_CTRL
|
2005-03-28 00:47:09 +00:00
|
|
|
|
snprintf(buf, 30, "Chgr: %s %s",
|
|
|
|
|
charger_inserted() ? "present" : "absent",
|
|
|
|
|
charger_enabled ? "on" : "off");
|
|
|
|
|
lcd_puts(0, 3, buf);
|
2005-03-03 07:25:43 +00:00
|
|
|
|
snprintf(buf, 30, "short delta: %d", short_delta);
|
2002-08-10 08:57:47 +00:00
|
|
|
|
lcd_puts(0, 5, buf);
|
2005-03-03 07:25:43 +00:00
|
|
|
|
snprintf(buf, 30, "long delta: %d", long_delta);
|
2002-08-10 08:57:47 +00:00
|
|
|
|
lcd_puts(0, 6, buf);
|
|
|
|
|
lcd_puts(0, 7, power_message);
|
2002-08-06 10:52:51 +00:00
|
|
|
|
#endif
|
2002-08-10 08:57:47 +00:00
|
|
|
|
break;
|
2002-08-06 10:52:51 +00:00
|
|
|
|
|
2002-08-10 08:57:47 +00:00
|
|
|
|
case 2: /* voltage deltas: */
|
|
|
|
|
lcd_clear_display();
|
|
|
|
|
lcd_puts(0, 0, "Voltage deltas:");
|
2002-08-06 10:52:51 +00:00
|
|
|
|
|
2002-08-10 08:57:47 +00:00
|
|
|
|
for (i = 0; i <= 6; i++) {
|
2005-03-03 07:25:43 +00:00
|
|
|
|
y = power_history[i] - power_history[i+i];
|
2002-08-10 08:57:47 +00:00
|
|
|
|
snprintf(buf, 30, "-%d min: %s%d.%02d V", i,
|
|
|
|
|
(y < 0) ? "-" : "", ((y < 0) ? y * -1 : y) / 100,
|
|
|
|
|
((y < 0) ? y * -1 : y ) % 100);
|
|
|
|
|
lcd_puts(0, i+1, buf);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2002-12-03 14:18:51 +00:00
|
|
|
|
|
2005-03-28 00:47:09 +00:00
|
|
|
|
case 3: /* remaining time estimation: */
|
2002-12-03 14:18:51 +00:00
|
|
|
|
lcd_clear_display();
|
2002-12-15 18:10:19 +00:00
|
|
|
|
|
2003-02-12 22:21:07 +00:00
|
|
|
|
#ifdef HAVE_CHARGE_CTRL
|
2002-12-15 18:10:19 +00:00
|
|
|
|
snprintf(buf, 30, "charge_state: %d", charge_state);
|
|
|
|
|
lcd_puts(0, 0, buf);
|
|
|
|
|
|
2002-12-03 14:18:51 +00:00
|
|
|
|
snprintf(buf, 30, "Cycle time: %d m", powermgmt_last_cycle_startstop_min);
|
|
|
|
|
lcd_puts(0, 1, buf);
|
|
|
|
|
|
2005-03-03 07:25:43 +00:00
|
|
|
|
snprintf(buf, 30, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level);
|
2002-12-03 14:18:51 +00:00
|
|
|
|
lcd_puts(0, 2, buf);
|
2005-03-28 00:47:09 +00:00
|
|
|
|
|
|
|
|
|
snprintf(buf, 30, "P=%2d I=%2d", pid_p, pid_i);
|
|
|
|
|
lcd_puts(0, 3, buf);
|
|
|
|
|
|
|
|
|
|
snprintf(buf, 30, "Trickle sec: %d/60", trickle_sec);
|
|
|
|
|
lcd_puts(0, 4, buf);
|
2003-02-12 22:21:07 +00:00
|
|
|
|
#endif
|
2002-12-03 14:18:51 +00:00
|
|
|
|
|
2005-03-03 07:25:43 +00:00
|
|
|
|
snprintf(buf, 30, "Last PwrHist: %d.%02d V",
|
|
|
|
|
power_history[0] / 100,
|
|
|
|
|
power_history[0] % 100);
|
2005-03-28 00:00:24 +00:00
|
|
|
|
lcd_puts(0, 5, buf);
|
2002-12-03 14:18:51 +00:00
|
|
|
|
|
2005-03-28 00:47:09 +00:00
|
|
|
|
snprintf(buf, 30, "battery level: %d%%", battery_level());
|
2005-03-28 00:00:24 +00:00
|
|
|
|
lcd_puts(0, 6, buf);
|
|
|
|
|
|
2005-03-28 00:47:09 +00:00
|
|
|
|
snprintf(buf, 30, "Est. remain: %d m", battery_time());
|
2002-12-14 12:10:29 +00:00
|
|
|
|
lcd_puts(0, 7, buf);
|
2002-12-03 14:18:51 +00:00
|
|
|
|
break;
|
2002-08-06 10:52:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lcd_update();
|
2002-08-12 12:21:22 +00:00
|
|
|
|
|
2002-12-03 14:18:51 +00:00
|
|
|
|
switch(button_get_w_tmo(HZ/2))
|
2002-08-06 10:52:51 +00:00
|
|
|
|
{
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_DEC:
|
2002-08-10 08:57:47 +00:00
|
|
|
|
if (view)
|
|
|
|
|
view--;
|
|
|
|
|
break;
|
2002-08-06 10:52:51 +00:00
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_INC:
|
2002-12-03 14:18:51 +00:00
|
|
|
|
if (view < 3)
|
2002-08-10 08:57:47 +00:00
|
|
|
|
view++;
|
|
|
|
|
break;
|
2002-08-06 10:52:51 +00:00
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_OK:
|
|
|
|
|
case SETTINGS_CANCEL:
|
2002-09-24 17:22:12 +00:00
|
|
|
|
return false;
|
2002-08-06 10:52:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-09-24 17:22:12 +00:00
|
|
|
|
return false;
|
2002-08-06 10:52:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-07-22 16:39:17 +00:00
|
|
|
|
#endif
|
2005-05-06 21:55:34 +00:00
|
|
|
|
|
2004-09-28 22:13:26 +00:00
|
|
|
|
#if CONFIG_HWCODEC == MAS3507D
|
2002-09-24 17:22:12 +00:00
|
|
|
|
bool dbg_mas_info(void)
|
2002-08-14 08:04:42 +00:00
|
|
|
|
{
|
|
|
|
|
int button;
|
|
|
|
|
char buf[32];
|
|
|
|
|
int currval = 0;
|
|
|
|
|
unsigned long val;
|
|
|
|
|
unsigned long pll48, pll44, config;
|
|
|
|
|
int pll_toggle = 0;
|
|
|
|
|
|
2002-08-20 22:13:20 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
lcd_setmargins(0, 0);
|
|
|
|
|
#endif
|
2002-08-14 08:04:42 +00:00
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
switch(currval)
|
|
|
|
|
{
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case 0:
|
|
|
|
|
mas_readmem(MAS_BANK_D1, 0xff7, &val, 1);
|
|
|
|
|
lcd_puts(0, 0, "Design Code");
|
2005-01-24 01:39:24 +00:00
|
|
|
|
snprintf(buf, 32, "%05lx ", val);
|
2004-09-19 21:58:37 +00:00
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
lcd_puts(0, 0, "DC/DC mode ");
|
|
|
|
|
snprintf(buf, 32, "8e: %05x ", mas_readreg(0x8e) & 0xfffff);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
lcd_puts(0, 0, "Mute/Bypass");
|
|
|
|
|
snprintf(buf, 32, "aa: %05x ", mas_readreg(0xaa) & 0xfffff);
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
lcd_puts(0, 0, "PIOData ");
|
|
|
|
|
snprintf(buf, 32, "ed: %05x ", mas_readreg(0xed) & 0xfffff);
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
lcd_puts(0, 0, "Startup Cfg");
|
|
|
|
|
snprintf(buf, 32, "e6: %05x ", mas_readreg(0xe6) & 0xfffff);
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
lcd_puts(0, 0, "KPrescale ");
|
|
|
|
|
snprintf(buf, 32, "e7: %05x ", mas_readreg(0xe7) & 0xfffff);
|
|
|
|
|
break;
|
|
|
|
|
case 6:
|
|
|
|
|
lcd_puts(0, 0, "KBass ");
|
|
|
|
|
snprintf(buf, 32, "6b: %05x ", mas_readreg(0x6b) & 0xfffff);
|
|
|
|
|
break;
|
|
|
|
|
case 7:
|
|
|
|
|
lcd_puts(0, 0, "KTreble ");
|
|
|
|
|
snprintf(buf, 32, "6f: %05x ", mas_readreg(0x6f) & 0xfffff);
|
|
|
|
|
break;
|
|
|
|
|
case 8:
|
2004-09-29 19:51:41 +00:00
|
|
|
|
mas_readmem(MAS_BANK_D0, MAS_D0_MPEG_FRAME_COUNT, &val, 1);
|
2004-09-19 21:58:37 +00:00
|
|
|
|
lcd_puts(0, 0, "Frame Count");
|
2005-01-24 01:39:24 +00:00
|
|
|
|
snprintf(buf, 32, "0/300: %04x", (unsigned int)(val & 0xffff));
|
2004-09-19 21:58:37 +00:00
|
|
|
|
break;
|
|
|
|
|
case 9:
|
2004-09-29 19:51:41 +00:00
|
|
|
|
mas_readmem(MAS_BANK_D0, MAS_D0_MPEG_STATUS_1, &val, 1);
|
2004-09-19 21:58:37 +00:00
|
|
|
|
lcd_puts(0, 0, "Status1 ");
|
2005-01-24 01:39:24 +00:00
|
|
|
|
snprintf(buf, 32, "0/301: %04x", (unsigned int)(val & 0xffff));
|
2004-09-19 21:58:37 +00:00
|
|
|
|
break;
|
|
|
|
|
case 10:
|
2004-09-29 19:51:41 +00:00
|
|
|
|
mas_readmem(MAS_BANK_D0, MAS_D0_MPEG_STATUS_2, &val, 1);
|
2004-09-19 21:58:37 +00:00
|
|
|
|
lcd_puts(0, 0, "Status2 ");
|
2005-01-24 01:39:24 +00:00
|
|
|
|
snprintf(buf, 32, "0/302: %04x", (unsigned int)(val & 0xffff));
|
2004-09-19 21:58:37 +00:00
|
|
|
|
break;
|
|
|
|
|
case 11:
|
2004-09-29 19:51:41 +00:00
|
|
|
|
mas_readmem(MAS_BANK_D0, MAS_D0_CRC_ERROR_COUNT, &val, 1);
|
2004-09-19 21:58:37 +00:00
|
|
|
|
lcd_puts(0, 0, "CRC Count ");
|
2005-01-24 01:39:24 +00:00
|
|
|
|
snprintf(buf, 32, "0/303: %04x", (unsigned int)(val & 0xffff));
|
2004-09-19 21:58:37 +00:00
|
|
|
|
break;
|
|
|
|
|
case 12:
|
|
|
|
|
mas_readmem(MAS_BANK_D0, 0x36d, &val, 1);
|
|
|
|
|
lcd_puts(0, 0, "PLLOffset48");
|
2005-01-24 01:39:24 +00:00
|
|
|
|
snprintf(buf, 32, "0/36d %05lx", val & 0xfffff);
|
2004-09-19 21:58:37 +00:00
|
|
|
|
break;
|
|
|
|
|
case 13:
|
|
|
|
|
mas_readmem(MAS_BANK_D0, 0x32d, &val, 1);
|
|
|
|
|
lcd_puts(0, 0, "PLLOffset48");
|
2005-01-24 01:39:24 +00:00
|
|
|
|
snprintf(buf, 32, "0/32d %05lx", val & 0xfffff);
|
2004-09-19 21:58:37 +00:00
|
|
|
|
break;
|
|
|
|
|
case 14:
|
|
|
|
|
mas_readmem(MAS_BANK_D0, 0x36e, &val, 1);
|
|
|
|
|
lcd_puts(0, 0, "PLLOffset44");
|
2005-01-24 01:39:24 +00:00
|
|
|
|
snprintf(buf, 32, "0/36e %05lx", val & 0xfffff);
|
2004-09-19 21:58:37 +00:00
|
|
|
|
break;
|
|
|
|
|
case 15:
|
|
|
|
|
mas_readmem(MAS_BANK_D0, 0x32e, &val, 1);
|
|
|
|
|
lcd_puts(0, 0, "PLLOffset44");
|
2005-01-24 01:39:24 +00:00
|
|
|
|
snprintf(buf, 32, "0/32e %05lx", val & 0xfffff);
|
2004-09-19 21:58:37 +00:00
|
|
|
|
break;
|
|
|
|
|
case 16:
|
|
|
|
|
mas_readmem(MAS_BANK_D0, 0x36f, &val, 1);
|
|
|
|
|
lcd_puts(0, 0, "OutputConf ");
|
2005-01-24 01:39:24 +00:00
|
|
|
|
snprintf(buf, 32, "0/36f %05lx", val & 0xfffff);
|
2004-09-19 21:58:37 +00:00
|
|
|
|
break;
|
|
|
|
|
case 17:
|
|
|
|
|
mas_readmem(MAS_BANK_D0, 0x32f, &val, 1);
|
|
|
|
|
lcd_puts(0, 0, "OutputConf ");
|
2005-01-24 01:39:24 +00:00
|
|
|
|
snprintf(buf, 32, "0/32f %05lx", val & 0xfffff);
|
2004-09-19 21:58:37 +00:00
|
|
|
|
break;
|
|
|
|
|
case 18:
|
|
|
|
|
mas_readmem(MAS_BANK_D1, 0x7f8, &val, 1);
|
|
|
|
|
lcd_puts(0, 0, "LL Gain ");
|
2005-01-24 01:39:24 +00:00
|
|
|
|
snprintf(buf, 32, "1/7f8 %05lx", val & 0xfffff);
|
2004-09-19 21:58:37 +00:00
|
|
|
|
break;
|
|
|
|
|
case 19:
|
|
|
|
|
mas_readmem(MAS_BANK_D1, 0x7f9, &val, 1);
|
|
|
|
|
lcd_puts(0, 0, "LR Gain ");
|
2005-01-24 01:39:24 +00:00
|
|
|
|
snprintf(buf, 32, "1/7f9 %05lx", val & 0xfffff);
|
2004-09-19 21:58:37 +00:00
|
|
|
|
break;
|
|
|
|
|
case 20:
|
|
|
|
|
mas_readmem(MAS_BANK_D1, 0x7fa, &val, 1);
|
|
|
|
|
lcd_puts(0, 0, "RL Gain ");
|
2005-01-24 01:39:24 +00:00
|
|
|
|
snprintf(buf, 32, "1/7fa %05lx", val & 0xfffff);
|
2004-09-19 21:58:37 +00:00
|
|
|
|
break;
|
|
|
|
|
case 21:
|
|
|
|
|
mas_readmem(MAS_BANK_D1, 0x7fb, &val, 1);
|
|
|
|
|
lcd_puts(0, 0, "RR Gain ");
|
2005-01-24 01:39:24 +00:00
|
|
|
|
snprintf(buf, 32, "1/7fb %05lx", val & 0xfffff);
|
2004-09-19 21:58:37 +00:00
|
|
|
|
break;
|
|
|
|
|
case 22:
|
|
|
|
|
lcd_puts(0, 0, "L Trailbits");
|
|
|
|
|
snprintf(buf, 32, "c5: %05x ", mas_readreg(0xc5) & 0xfffff);
|
|
|
|
|
break;
|
|
|
|
|
case 23:
|
|
|
|
|
lcd_puts(0, 0, "R Trailbits");
|
|
|
|
|
snprintf(buf, 32, "c6: %05x ", mas_readreg(0xc6) & 0xfffff);
|
|
|
|
|
break;
|
2002-08-14 08:04:42 +00:00
|
|
|
|
}
|
|
|
|
|
lcd_puts(0, 1, buf);
|
|
|
|
|
|
|
|
|
|
button = button_get_w_tmo(HZ/5);
|
|
|
|
|
switch(button)
|
|
|
|
|
{
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_CANCEL:
|
|
|
|
|
return false;
|
2002-08-14 08:04:42 +00:00
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_DEC:
|
|
|
|
|
currval--;
|
|
|
|
|
if(currval < 0)
|
|
|
|
|
currval = 23;
|
|
|
|
|
break;
|
2002-08-14 08:04:42 +00:00
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_INC:
|
|
|
|
|
currval++;
|
|
|
|
|
if(currval > 23)
|
|
|
|
|
currval = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SETTINGS_OK:
|
|
|
|
|
pll_toggle = !pll_toggle;
|
|
|
|
|
if(pll_toggle)
|
|
|
|
|
{
|
|
|
|
|
/* 14.31818 MHz crystal */
|
|
|
|
|
pll48 = 0x5d9d0;
|
|
|
|
|
pll44 = 0xfffceceb;
|
|
|
|
|
config = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* 14.725 MHz crystal */
|
|
|
|
|
pll48 = 0x2d0de;
|
|
|
|
|
pll44 = 0xfffa2319;
|
|
|
|
|
config = 0;
|
|
|
|
|
}
|
|
|
|
|
mas_writemem(MAS_BANK_D0, 0x32d, &pll48, 1);
|
|
|
|
|
mas_writemem(MAS_BANK_D0, 0x32e, &pll44, 1);
|
|
|
|
|
mas_writemem(MAS_BANK_D0, 0x32f, &config, 1);
|
|
|
|
|
mas_run(0x475);
|
|
|
|
|
break;
|
2002-08-14 08:04:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-09-24 17:22:12 +00:00
|
|
|
|
return false;
|
2002-08-14 08:04:42 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-12-02 16:07:56 +00:00
|
|
|
|
static bool view_runtime(void)
|
|
|
|
|
{
|
|
|
|
|
char s[32];
|
|
|
|
|
bool done = false;
|
|
|
|
|
int state = 1;
|
|
|
|
|
|
|
|
|
|
while(!done)
|
|
|
|
|
{
|
|
|
|
|
int y=0;
|
|
|
|
|
int t;
|
|
|
|
|
int key;
|
|
|
|
|
lcd_clear_display();
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
lcd_puts(0, y++, "Running time:");
|
|
|
|
|
y++;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (state & 1) {
|
2003-10-17 13:54:48 +00:00
|
|
|
|
if (charger_inserted())
|
|
|
|
|
{
|
|
|
|
|
global_settings.runtime = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
global_settings.runtime += ((current_tick - lasttime) / HZ);
|
|
|
|
|
}
|
|
|
|
|
lasttime = current_tick;
|
|
|
|
|
|
2002-12-02 16:07:56 +00:00
|
|
|
|
t = global_settings.runtime;
|
|
|
|
|
lcd_puts(0, y++, "Current time");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
t = global_settings.topruntime;
|
|
|
|
|
lcd_puts(0, y++, "Top time");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
snprintf(s, sizeof(s), "%dh %dm %ds",
|
|
|
|
|
t / 3600, (t % 3600) / 60, t % 60);
|
|
|
|
|
lcd_puts(0, y++, s);
|
|
|
|
|
lcd_update();
|
|
|
|
|
|
|
|
|
|
/* Wait for a key to be pushed */
|
2003-10-17 13:54:48 +00:00
|
|
|
|
key = button_get_w_tmo(HZ);
|
2002-12-02 16:07:56 +00:00
|
|
|
|
switch(key) {
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_CANCEL:
|
2002-12-02 16:07:56 +00:00
|
|
|
|
done = true;
|
|
|
|
|
break;
|
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_INC:
|
|
|
|
|
case SETTINGS_DEC:
|
2002-12-02 16:07:56 +00:00
|
|
|
|
if (state == 1)
|
|
|
|
|
state = 2;
|
|
|
|
|
else
|
|
|
|
|
state = 1;
|
|
|
|
|
break;
|
2004-09-19 21:58:37 +00:00
|
|
|
|
|
|
|
|
|
case SETTINGS_OK:
|
2002-12-02 16:07:56 +00:00
|
|
|
|
lcd_clear_display();
|
|
|
|
|
lcd_puts(0,0,"Clear time?");
|
|
|
|
|
lcd_puts(0,1,"PLAY = Yes");
|
|
|
|
|
lcd_update();
|
|
|
|
|
while (1) {
|
2004-10-16 07:49:57 +00:00
|
|
|
|
key = button_get(true);
|
2004-09-19 21:58:37 +00:00
|
|
|
|
if ( key == SETTINGS_OK ) {
|
2002-12-02 16:07:56 +00:00
|
|
|
|
if ( state == 1 )
|
|
|
|
|
global_settings.runtime = 0;
|
|
|
|
|
else
|
|
|
|
|
global_settings.topruntime = 0;
|
2004-09-23 19:38:59 +00:00
|
|
|
|
break;
|
2002-12-02 16:07:56 +00:00
|
|
|
|
}
|
2004-10-16 07:49:57 +00:00
|
|
|
|
if (!(key & BUTTON_REL)) /* ignore button releases */
|
2004-09-23 19:38:59 +00:00
|
|
|
|
break;
|
2002-12-02 16:07:56 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-28 06:23:57 +00:00
|
|
|
|
#ifdef HAVE_MMC
|
2004-10-06 20:43:12 +00:00
|
|
|
|
bool dbg_mmc_info(void)
|
2004-09-28 06:23:57 +00:00
|
|
|
|
{
|
2004-10-06 20:43:12 +00:00
|
|
|
|
bool done = false;
|
|
|
|
|
int currval = 0;
|
|
|
|
|
tCardInfo *card;
|
2005-01-31 00:39:20 +00:00
|
|
|
|
unsigned char pbuf[32], pbuf2[32];
|
2004-10-06 20:43:12 +00:00
|
|
|
|
unsigned char card_name[7];
|
2005-01-31 00:39:20 +00:00
|
|
|
|
|
2004-10-06 20:43:12 +00:00
|
|
|
|
static const unsigned char i_vmin[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
|
|
|
|
|
static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
|
2005-01-31 00:39:20 +00:00
|
|
|
|
static const unsigned char *kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" };
|
|
|
|
|
static const unsigned char *nsec_units[] = { "ns", "<EFBFBD>s", "ms" };
|
2004-10-06 20:43:12 +00:00
|
|
|
|
|
|
|
|
|
card_name[6] = '\0';
|
|
|
|
|
|
|
|
|
|
lcd_setmargins(0, 0);
|
|
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
|
|
|
|
|
|
|
|
|
while (!done)
|
|
|
|
|
{
|
|
|
|
|
card = mmc_card_info(currval / 2);
|
|
|
|
|
|
|
|
|
|
lcd_clear_display();
|
|
|
|
|
snprintf(pbuf, sizeof(pbuf), "[MMC%d p%d]", currval / 2,
|
|
|
|
|
(currval % 2) + 1);
|
|
|
|
|
lcd_puts(0, 0, pbuf);
|
|
|
|
|
|
|
|
|
|
if (card->initialized)
|
|
|
|
|
{
|
|
|
|
|
if (!(currval % 2)) /* General info */
|
|
|
|
|
{
|
|
|
|
|
strncpy(card_name, ((unsigned char*)card->cid) + 3, 6);
|
|
|
|
|
snprintf(pbuf, sizeof(pbuf), "%s Rev %d.%d", card_name,
|
2005-01-24 01:39:24 +00:00
|
|
|
|
(int) mmc_extract_bits(card->cid, 72, 4),
|
|
|
|
|
(int) mmc_extract_bits(card->cid, 76, 4));
|
2004-10-06 20:43:12 +00:00
|
|
|
|
lcd_puts(0, 1, pbuf);
|
|
|
|
|
snprintf(pbuf, sizeof(pbuf), "Prod: %d/%d",
|
2005-01-24 01:39:24 +00:00
|
|
|
|
(int) mmc_extract_bits(card->cid, 112, 4),
|
|
|
|
|
(int) mmc_extract_bits(card->cid, 116, 4) + 1997);
|
2004-10-06 20:43:12 +00:00
|
|
|
|
lcd_puts(0, 2, pbuf);
|
2005-01-24 01:39:24 +00:00
|
|
|
|
snprintf(pbuf, sizeof(pbuf), "Ser#: 0x%08lx",
|
2004-10-06 20:43:12 +00:00
|
|
|
|
mmc_extract_bits(card->cid, 80, 32));
|
|
|
|
|
lcd_puts(0, 3, pbuf);
|
|
|
|
|
snprintf(pbuf, sizeof(pbuf), "M=%02x, O=%04x",
|
2005-01-24 01:39:24 +00:00
|
|
|
|
(int) mmc_extract_bits(card->cid, 0, 8),
|
|
|
|
|
(int) mmc_extract_bits(card->cid, 8, 16));
|
2004-10-06 20:43:12 +00:00
|
|
|
|
lcd_puts(0, 4, pbuf);
|
2005-05-27 21:47:50 +00:00
|
|
|
|
snprintf(pbuf, sizeof(pbuf), "Blocks: 0x%06lx", card->numblocks);
|
2004-10-06 20:43:12 +00:00
|
|
|
|
lcd_puts(0, 5, pbuf);
|
2005-05-27 21:47:50 +00:00
|
|
|
|
snprintf(pbuf, sizeof(pbuf), "Blksz.: %d", card->blocksize);
|
2005-04-28 01:11:21 +00:00
|
|
|
|
lcd_puts(0, 6, pbuf);
|
2004-10-06 20:43:12 +00:00
|
|
|
|
}
|
|
|
|
|
else /* Technical details */
|
|
|
|
|
{
|
2005-01-31 00:39:20 +00:00
|
|
|
|
output_dyn_value(pbuf2, sizeof pbuf2, card->speed / 1000,
|
|
|
|
|
kbit_units, false);
|
|
|
|
|
snprintf(pbuf, sizeof pbuf, "Speed: %s", pbuf2);
|
2004-10-06 20:43:12 +00:00
|
|
|
|
lcd_puts(0, 1, pbuf);
|
|
|
|
|
|
2005-01-31 00:39:20 +00:00
|
|
|
|
output_dyn_value(pbuf2, sizeof pbuf2, card->tsac,
|
|
|
|
|
nsec_units, false);
|
|
|
|
|
snprintf(pbuf, sizeof pbuf, "Tsac: %s", pbuf2);
|
2004-10-07 01:23:44 +00:00
|
|
|
|
lcd_puts(0, 2, pbuf);
|
2004-10-06 20:43:12 +00:00
|
|
|
|
|
|
|
|
|
snprintf(pbuf, sizeof(pbuf), "Nsac: %d clk", card->nsac);
|
|
|
|
|
lcd_puts(0, 3, pbuf);
|
2004-10-07 01:23:44 +00:00
|
|
|
|
snprintf(pbuf, sizeof(pbuf), "R2W: *%d", card->r2w_factor);
|
|
|
|
|
lcd_puts(0, 4, pbuf);
|
2004-10-06 20:43:12 +00:00
|
|
|
|
snprintf(pbuf, sizeof(pbuf), "IRmax: %d..%d mA",
|
|
|
|
|
i_vmin[mmc_extract_bits(card->csd, 66, 3)],
|
|
|
|
|
i_vmax[mmc_extract_bits(card->csd, 69, 3)]);
|
2004-10-07 01:23:44 +00:00
|
|
|
|
lcd_puts(0, 5, pbuf);
|
2004-10-06 20:43:12 +00:00
|
|
|
|
snprintf(pbuf, sizeof(pbuf), "IWmax: %d..%d mA",
|
|
|
|
|
i_vmin[mmc_extract_bits(card->csd, 72, 3)],
|
|
|
|
|
i_vmax[mmc_extract_bits(card->csd, 75, 3)]);
|
2004-10-07 01:23:44 +00:00
|
|
|
|
lcd_puts(0, 6, pbuf);
|
2004-10-06 20:43:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
lcd_puts(0, 1, "Not found!");
|
|
|
|
|
|
|
|
|
|
lcd_update();
|
|
|
|
|
|
2004-10-10 00:35:19 +00:00
|
|
|
|
switch (button_get_w_tmo(HZ/2))
|
2004-10-06 20:43:12 +00:00
|
|
|
|
{
|
|
|
|
|
case SETTINGS_OK:
|
|
|
|
|
case SETTINGS_CANCEL:
|
|
|
|
|
done = true;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SETTINGS_DEC:
|
|
|
|
|
currval--;
|
|
|
|
|
if (currval < 0)
|
|
|
|
|
currval = 3;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SETTINGS_INC:
|
|
|
|
|
currval++;
|
|
|
|
|
if (currval > 3)
|
|
|
|
|
currval = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-09-28 06:23:57 +00:00
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
#else /* Disk-based jukebox */
|
2002-12-03 13:12:55 +00:00
|
|
|
|
static bool dbg_disk_info(void)
|
|
|
|
|
{
|
|
|
|
|
char buf[128];
|
|
|
|
|
bool done = false;
|
|
|
|
|
int i;
|
|
|
|
|
int page = 0;
|
2004-04-06 00:17:02 +00:00
|
|
|
|
const int max_page = 11;
|
2002-12-03 13:12:55 +00:00
|
|
|
|
unsigned short* identify_info = ata_get_identify();
|
2004-02-16 12:04:55 +00:00
|
|
|
|
bool timing_info_present = false;
|
|
|
|
|
char pio3[2], pio4[2];
|
2002-12-03 13:12:55 +00:00
|
|
|
|
|
2004-02-16 12:21:07 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2004-02-16 12:04:55 +00:00
|
|
|
|
lcd_setmargins(0, 0);
|
2004-02-16 12:21:07 +00:00
|
|
|
|
#endif
|
2004-02-16 12:04:55 +00:00
|
|
|
|
|
2002-12-03 13:12:55 +00:00
|
|
|
|
while(!done)
|
|
|
|
|
{
|
|
|
|
|
int y=0;
|
|
|
|
|
int key;
|
|
|
|
|
lcd_clear_display();
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
lcd_puts(0, y++, "Disk info:");
|
|
|
|
|
y++;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
switch (page) {
|
2003-08-05 13:39:38 +00:00
|
|
|
|
case 0:
|
|
|
|
|
for (i=0; i < 20; i++)
|
|
|
|
|
((unsigned short*)buf)[i]=identify_info[i+27];
|
|
|
|
|
buf[40]=0;
|
|
|
|
|
/* kill trailing space */
|
|
|
|
|
for (i=39; i && buf[i]==' '; i--)
|
|
|
|
|
buf[i] = 0;
|
|
|
|
|
lcd_puts(0, y++, "Model");
|
|
|
|
|
lcd_puts_scroll(0, y++, buf);
|
|
|
|
|
break;
|
2002-12-03 13:12:55 +00:00
|
|
|
|
|
2003-08-05 13:39:38 +00:00
|
|
|
|
case 1:
|
|
|
|
|
for (i=0; i < 4; i++)
|
|
|
|
|
((unsigned short*)buf)[i]=identify_info[i+23];
|
|
|
|
|
buf[8]=0;
|
|
|
|
|
lcd_puts(0, y++, "Firmware");
|
|
|
|
|
lcd_puts(0, y++, buf);
|
|
|
|
|
break;
|
2002-12-03 13:12:55 +00:00
|
|
|
|
|
2003-08-05 13:39:38 +00:00
|
|
|
|
case 2:
|
2005-02-08 15:12:25 +00:00
|
|
|
|
snprintf(buf, sizeof buf, "%ld MB",
|
|
|
|
|
((unsigned long)identify_info[61] << 16 |
|
|
|
|
|
(unsigned long)identify_info[60]) / 2048 );
|
2003-08-05 13:39:38 +00:00
|
|
|
|
lcd_puts(0, y++, "Size");
|
|
|
|
|
lcd_puts(0, y++, buf);
|
|
|
|
|
break;
|
2002-12-04 14:58:48 +00:00
|
|
|
|
|
2003-08-05 13:39:38 +00:00
|
|
|
|
case 3: {
|
2005-01-24 01:39:24 +00:00
|
|
|
|
unsigned long free;
|
2004-12-29 22:37:31 +00:00
|
|
|
|
fat_size( IF_MV2(0,) NULL, &free );
|
2005-01-24 01:39:24 +00:00
|
|
|
|
snprintf(buf, sizeof buf, "%ld MB", free / 1024 );
|
2003-08-05 13:39:38 +00:00
|
|
|
|
lcd_puts(0, y++, "Free");
|
|
|
|
|
lcd_puts(0, y++, buf);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-12-09 15:39:32 +00:00
|
|
|
|
|
2003-08-05 13:39:38 +00:00
|
|
|
|
case 4:
|
|
|
|
|
snprintf(buf, sizeof buf, "%d ms", ata_spinup_time * (1000/HZ));
|
|
|
|
|
lcd_puts(0, y++, "Spinup time");
|
|
|
|
|
lcd_puts(0, y++, buf);
|
|
|
|
|
break;
|
2004-01-14 15:08:55 +00:00
|
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
|
i = identify_info[83] & (1<<3);
|
|
|
|
|
lcd_puts(0, y++, "Power mgmt:");
|
|
|
|
|
lcd_puts(0, y++, i ? "enabled" : "unsupported");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
|
i = identify_info[83] & (1<<9);
|
|
|
|
|
lcd_puts(0, y++, "Noise mgmt:");
|
|
|
|
|
lcd_puts(0, y++, i ? "enabled" : "unsupported");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 7:
|
2004-01-14 15:10:17 +00:00
|
|
|
|
i = identify_info[82] & (1<<6);
|
2004-01-14 15:08:55 +00:00
|
|
|
|
lcd_puts(0, y++, "Read-ahead:");
|
|
|
|
|
lcd_puts(0, y++, i ? "enabled" : "unsupported");
|
|
|
|
|
break;
|
2004-02-16 12:04:55 +00:00
|
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
|
timing_info_present = identify_info[53] & (1<<1);
|
|
|
|
|
if(timing_info_present) {
|
|
|
|
|
pio3[1] = 0;
|
|
|
|
|
pio4[1] = 0;
|
|
|
|
|
lcd_puts(0, y++, "PIO modes:");
|
|
|
|
|
pio3[0] = (identify_info[64] & (1<<0)) ? '3' : 0;
|
|
|
|
|
pio4[0] = (identify_info[64] & (1<<1)) ? '4' : 0;
|
|
|
|
|
snprintf(buf, 128, "0 1 2 %s %s", pio3, pio4);
|
|
|
|
|
lcd_puts(0, y++, buf);
|
|
|
|
|
} else {
|
|
|
|
|
lcd_puts(0, y++, "No PIO mode info");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 9:
|
|
|
|
|
timing_info_present = identify_info[53] & (1<<1);
|
|
|
|
|
if(timing_info_present) {
|
2004-03-01 09:42:47 +00:00
|
|
|
|
lcd_puts(0, y++, "Cycle times");
|
|
|
|
|
snprintf(buf, 128, "%dns/%dns",
|
|
|
|
|
identify_info[67],
|
|
|
|
|
identify_info[68]);
|
2004-02-16 12:04:55 +00:00
|
|
|
|
lcd_puts(0, y++, buf);
|
|
|
|
|
} else {
|
|
|
|
|
lcd_puts(0, y++, "No timing info");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 10:
|
|
|
|
|
timing_info_present = identify_info[53] & (1<<1);
|
|
|
|
|
if(timing_info_present) {
|
|
|
|
|
i = identify_info[49] & (1<<11);
|
|
|
|
|
snprintf(buf, 128, "IORDY support: %s", i ? "yes" : "no");
|
|
|
|
|
lcd_puts(0, y++, buf);
|
|
|
|
|
i = identify_info[49] & (1<<10);
|
|
|
|
|
snprintf(buf, 128, "IORDY disable: %s", i ? "yes" : "no");
|
|
|
|
|
lcd_puts(0, y++, buf);
|
|
|
|
|
} else {
|
|
|
|
|
lcd_puts(0, y++, "No timing info");
|
|
|
|
|
}
|
|
|
|
|
break;
|
2004-04-06 00:17:02 +00:00
|
|
|
|
|
|
|
|
|
case 11:
|
|
|
|
|
lcd_puts(0, y++, "Cluster size");
|
2004-12-29 22:37:31 +00:00
|
|
|
|
snprintf(buf, 128, "%d bytes", fat_get_cluster_size(IF_MV(0)));
|
2004-04-06 00:17:02 +00:00
|
|
|
|
lcd_puts(0, y++, buf);
|
|
|
|
|
break;
|
2002-12-03 13:12:55 +00:00
|
|
|
|
}
|
|
|
|
|
lcd_update();
|
|
|
|
|
|
|
|
|
|
/* Wait for a key to be pushed */
|
|
|
|
|
key = button_get_w_tmo(HZ*5);
|
|
|
|
|
switch(key) {
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_CANCEL:
|
2002-12-03 13:12:55 +00:00
|
|
|
|
done = true;
|
|
|
|
|
break;
|
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_DEC:
|
2002-12-03 13:12:55 +00:00
|
|
|
|
if (--page < 0)
|
|
|
|
|
page = max_page;
|
|
|
|
|
break;
|
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_INC:
|
2002-12-03 13:12:55 +00:00
|
|
|
|
if (++page > max_page)
|
|
|
|
|
page = 0;
|
|
|
|
|
break;
|
2002-12-09 15:39:32 +00:00
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_OK:
|
2002-12-09 15:39:32 +00:00
|
|
|
|
if (page == 3) {
|
2005-04-04 12:06:29 +00:00
|
|
|
|
audio_stop(); /* stop playback, to avoid disk access */
|
2002-12-09 15:39:32 +00:00
|
|
|
|
lcd_clear_display();
|
|
|
|
|
lcd_puts(0,0,"Scanning");
|
|
|
|
|
lcd_puts(0,1,"disk...");
|
|
|
|
|
lcd_update();
|
2004-12-29 22:37:31 +00:00
|
|
|
|
fat_recalc_free(IF_MV(0));
|
2002-12-09 15:39:32 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2002-12-03 13:12:55 +00:00
|
|
|
|
}
|
|
|
|
|
lcd_stop_scroll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2004-09-28 06:23:57 +00:00
|
|
|
|
#endif
|
2002-12-03 13:12:55 +00:00
|
|
|
|
|
2005-02-02 21:57:40 +00:00
|
|
|
|
#if CONFIG_CPU == SH7034
|
2003-05-17 21:24:13 +00:00
|
|
|
|
bool dbg_save_roms(void)
|
|
|
|
|
{
|
|
|
|
|
int fd;
|
2004-08-30 19:52:45 +00:00
|
|
|
|
int oldmode = system_memory_guard(MEMGUARD_NONE);
|
2003-05-17 21:24:13 +00:00
|
|
|
|
|
|
|
|
|
fd = creat("/internal_rom_0000-FFFF.bin", O_WRONLY);
|
|
|
|
|
if(fd >= 0)
|
|
|
|
|
{
|
|
|
|
|
write(fd, (void *)0, 0x10000);
|
|
|
|
|
close(fd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fd = creat("/internal_rom_2000000-203FFFF.bin", O_WRONLY);
|
|
|
|
|
if(fd >= 0)
|
|
|
|
|
{
|
|
|
|
|
write(fd, (void *)0x2000000, 0x40000);
|
|
|
|
|
close(fd);
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-30 19:52:45 +00:00
|
|
|
|
system_memory_guard(oldmode);
|
2003-05-17 21:24:13 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2005-02-02 21:57:40 +00:00
|
|
|
|
#endif /* CONFIG_CPU == SH7034 */
|
2003-05-17 21:24:13 +00:00
|
|
|
|
|
2004-09-28 22:13:26 +00:00
|
|
|
|
#ifdef CONFIG_TUNER
|
2004-02-04 09:53:22 +00:00
|
|
|
|
bool dbg_fm_radio(void)
|
|
|
|
|
{
|
|
|
|
|
char buf[32];
|
|
|
|
|
int button;
|
|
|
|
|
bool fm_detected;
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
lcd_setmargins(0, 0);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
lcd_clear_display();
|
|
|
|
|
fm_detected = radio_hardware_present();
|
|
|
|
|
|
|
|
|
|
snprintf(buf, sizeof buf, "HW detected: %s", fm_detected?"yes":"no");
|
|
|
|
|
lcd_puts(0, 0, buf);
|
|
|
|
|
lcd_update();
|
|
|
|
|
|
|
|
|
|
button = button_get(true);
|
|
|
|
|
|
|
|
|
|
switch(button)
|
|
|
|
|
{
|
2004-09-19 21:58:37 +00:00
|
|
|
|
case SETTINGS_CANCEL:
|
2004-02-04 09:53:22 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-06-30 13:31:14 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
extern bool do_screendump_instead_of_usb;
|
|
|
|
|
|
|
|
|
|
bool dbg_screendump(void)
|
|
|
|
|
{
|
|
|
|
|
do_screendump_instead_of_usb = !do_screendump_instead_of_usb;
|
|
|
|
|
splash(HZ, true, "Screendump %s",
|
|
|
|
|
do_screendump_instead_of_usb?"enabled":"disabled");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-02-02 21:57:40 +00:00
|
|
|
|
#if CONFIG_CPU == SH7034
|
2004-08-30 19:52:45 +00:00
|
|
|
|
bool dbg_set_memory_guard(void)
|
|
|
|
|
{
|
|
|
|
|
static const struct opt_items names[MAXMEMGUARD] = {
|
|
|
|
|
{ "None", -1 },
|
|
|
|
|
{ "Flash ROM writes", -1 },
|
|
|
|
|
{ "Zero area (all)", -1 }
|
|
|
|
|
};
|
|
|
|
|
int mode = system_memory_guard(MEMGUARD_KEEP);
|
|
|
|
|
|
|
|
|
|
set_option( "Catch mem accesses", &mode, INT, names, MAXMEMGUARD, NULL);
|
|
|
|
|
system_memory_guard(mode);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2005-02-02 21:57:40 +00:00
|
|
|
|
#endif /* CONFIG_CPU == SH7034 */
|
2004-08-30 19:52:45 +00:00
|
|
|
|
|
2002-09-24 17:22:12 +00:00
|
|
|
|
bool debug_menu(void)
|
2002-07-15 11:23:24 +00:00
|
|
|
|
{
|
|
|
|
|
int m;
|
2002-09-24 17:22:12 +00:00
|
|
|
|
bool result;
|
2002-07-15 11:23:24 +00:00
|
|
|
|
|
2004-07-23 23:01:20 +00:00
|
|
|
|
static const struct menu_item items[] = {
|
2005-02-02 21:57:40 +00:00
|
|
|
|
#if CONFIG_CPU == SH7034
|
2004-07-23 23:01:20 +00:00
|
|
|
|
{ "Dump ROM contents", dbg_save_roms },
|
2005-02-11 13:16:09 +00:00
|
|
|
|
#endif
|
|
|
|
|
#if CONFIG_CPU == SH7034 || CONFIG_CPU == MCF5249
|
2004-07-23 23:01:20 +00:00
|
|
|
|
{ "View I/O ports", dbg_ports },
|
2005-02-11 13:16:09 +00:00
|
|
|
|
#endif
|
2005-03-07 10:51:43 +00:00
|
|
|
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
|
|
|
|
{ "CPU frequency", dbg_cpufreq },
|
2005-03-18 12:47:06 +00:00
|
|
|
|
#endif
|
2005-06-19 03:05:53 +00:00
|
|
|
|
#if defined(IRIVER_H100) && !defined(SIMULATOR)
|
|
|
|
|
{ "PCM recording", pcm_rec_screen },
|
|
|
|
|
#endif
|
2005-02-11 13:16:09 +00:00
|
|
|
|
#if CONFIG_CPU == SH7034
|
2002-07-15 22:25:45 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-07-15 11:23:24 +00:00
|
|
|
|
#ifdef HAVE_RTC
|
2004-07-23 23:01:20 +00:00
|
|
|
|
{ "View/clr RTC RAM", dbg_rtc },
|
2002-07-15 11:23:24 +00:00
|
|
|
|
#endif /* HAVE_RTC */
|
|
|
|
|
#endif /* HAVE_LCD_BITMAP */
|
2004-08-30 19:52:45 +00:00
|
|
|
|
{ "Catch mem accesses", dbg_set_memory_guard },
|
2005-02-02 21:57:40 +00:00
|
|
|
|
#endif /* CONFIG_CPU == SH7034 */
|
|
|
|
|
{ "View OS stacks", dbg_os },
|
2004-09-28 22:13:26 +00:00
|
|
|
|
#if CONFIG_HWCODEC == MAS3507D
|
2004-07-23 23:01:20 +00:00
|
|
|
|
{ "View MAS info", dbg_mas_info },
|
2002-08-14 08:04:42 +00:00
|
|
|
|
#endif
|
2005-02-02 21:57:40 +00:00
|
|
|
|
#if CONFIG_HWCODEC != MASNONE
|
2004-07-23 23:01:20 +00:00
|
|
|
|
{ "View MAS regs", dbg_mas },
|
2005-02-02 21:57:40 +00:00
|
|
|
|
#endif
|
2004-09-29 19:51:41 +00:00
|
|
|
|
#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
|
2004-07-23 23:01:20 +00:00
|
|
|
|
{ "View MAS codec", dbg_mas_codec },
|
2002-08-08 20:44:25 +00:00
|
|
|
|
#endif
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2004-07-23 23:01:20 +00:00
|
|
|
|
{ "View battery", view_battery },
|
|
|
|
|
{ "Screendump", dbg_screendump },
|
2002-07-22 16:39:17 +00:00
|
|
|
|
#endif
|
2004-07-23 23:01:20 +00:00
|
|
|
|
{ "View HW info", dbg_hw_info },
|
|
|
|
|
{ "View partitions", dbg_partitions },
|
2004-09-28 06:23:57 +00:00
|
|
|
|
#ifdef HAVE_MMC
|
|
|
|
|
{ "View MMC info", dbg_mmc_info },
|
|
|
|
|
#else
|
2004-07-23 23:01:20 +00:00
|
|
|
|
{ "View disk info", dbg_disk_info },
|
2004-09-28 06:23:57 +00:00
|
|
|
|
#endif
|
2005-06-22 14:03:04 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2005-04-04 12:06:29 +00:00
|
|
|
|
{ "View audio thread", dbg_audio_thread },
|
2002-10-29 12:09:15 +00:00
|
|
|
|
#ifdef PM_DEBUG
|
2004-07-23 23:01:20 +00:00
|
|
|
|
{ "pm histogram", peak_meter_histogram},
|
2002-10-29 12:09:15 +00:00
|
|
|
|
#endif /* PM_DEBUG */
|
|
|
|
|
#endif /* HAVE_LCD_BITMAP */
|
2004-07-23 23:01:20 +00:00
|
|
|
|
{ "View runtime", view_runtime },
|
2004-09-28 22:13:26 +00:00
|
|
|
|
#ifdef CONFIG_TUNER
|
2004-07-23 23:01:20 +00:00
|
|
|
|
{ "FM Radio", dbg_fm_radio },
|
2005-05-30 13:00:43 +00:00
|
|
|
|
#endif
|
|
|
|
|
#ifdef ROCKBOX_HAS_LOGF
|
|
|
|
|
{"logf", logfdisplay },
|
2005-06-01 13:07:37 +00:00
|
|
|
|
{"logfdump", logfdump },
|
2004-02-04 09:53:22 +00:00
|
|
|
|
#endif
|
2002-07-15 11:23:24 +00:00
|
|
|
|
};
|
|
|
|
|
|
2004-03-16 13:44:56 +00:00
|
|
|
|
m=menu_init( items, sizeof items / sizeof(struct menu_item), NULL,
|
|
|
|
|
NULL, NULL, NULL);
|
2002-08-23 12:32:52 +00:00
|
|
|
|
result = menu_run(m);
|
2002-07-15 11:23:24 +00:00
|
|
|
|
menu_exit(m);
|
2002-08-23 12:32:52 +00:00
|
|
|
|
|
|
|
|
|
return result;
|
2002-07-15 11:23:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* SIMULATOR */
|