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>
|
|
|
|
#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-07-15 11:23:24 +00:00
|
|
|
|
|
|
|
/*---------------------------------------------------*/
|
|
|
|
/* SPECIAL DEBUG STUFF */
|
|
|
|
/*---------------------------------------------------*/
|
|
|
|
extern int ata_device;
|
|
|
|
extern int ata_io_address;
|
2002-07-15 22:25:45 +00:00
|
|
|
extern int num_threads;
|
|
|
|
extern char *thread_name[];
|
|
|
|
|
2002-08-08 20:44:25 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-07-15 22:25:45 +00:00
|
|
|
/* Test code!!! */
|
2002-08-23 12:47:59 +00:00
|
|
|
Menu 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();
|
|
|
|
sleep(HZ/10);
|
|
|
|
|
|
|
|
button = button_get(false);
|
|
|
|
|
|
|
|
switch(button)
|
|
|
|
{
|
2002-08-10 08:57:47 +00:00
|
|
|
case BUTTON_OFF:
|
|
|
|
case BUTTON_LEFT:
|
2002-08-23 13:04:16 +00:00
|
|
|
return MENU_OK;
|
2002-07-15 22:25:45 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-23 13:04:16 +00:00
|
|
|
return MENU_OK;
|
2002-07-15 22:25:45 +00:00
|
|
|
}
|
|
|
|
#else
|
2002-08-23 12:32:52 +00:00
|
|
|
Menu 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);
|
2002-07-15 22:25:45 +00:00
|
|
|
|
|
|
|
sleep(HZ/10);
|
|
|
|
|
|
|
|
button = button_get(false);
|
|
|
|
|
|
|
|
switch(button)
|
|
|
|
{
|
2002-08-10 08:52:11 +00:00
|
|
|
case BUTTON_STOP:
|
2002-08-23 12:32:52 +00:00
|
|
|
return MENU_OK;
|
2002-07-15 22:25:45 +00:00
|
|
|
|
|
|
|
case BUTTON_LEFT:
|
2002-08-10 08:52:11 +00:00
|
|
|
currval--;
|
|
|
|
if(currval < 0)
|
|
|
|
currval = num_threads-1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BUTTON_RIGHT:
|
|
|
|
currval++;
|
|
|
|
if(currval > num_threads-1)
|
|
|
|
currval = 0;
|
|
|
|
break;
|
2002-07-15 22:25:45 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-23 12:32:52 +00:00
|
|
|
return MENU_OK;
|
2002-07-15 22:25:45 +00:00
|
|
|
}
|
|
|
|
#endif
|
2002-07-15 11:23:24 +00:00
|
|
|
|
2002-08-08 20:44:25 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-07-15 11:23:24 +00:00
|
|
|
/* Test code!!! */
|
2002-08-23 12:32:52 +00:00
|
|
|
Menu 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;
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
snprintf(buf, 32, "ATA: %s, 0x%x",
|
|
|
|
ata_device?"slave":"master", ata_io_address);
|
|
|
|
lcd_puts(0, 7, buf);
|
|
|
|
|
|
|
|
lcd_update();
|
|
|
|
sleep(HZ/10);
|
|
|
|
|
|
|
|
button = button_get(false);
|
|
|
|
|
|
|
|
switch(button)
|
|
|
|
{
|
2002-08-10 08:57:47 +00:00
|
|
|
case BUTTON_OFF:
|
|
|
|
case BUTTON_LEFT:
|
2002-08-23 12:32:52 +00:00
|
|
|
return MENU_OK;
|
2002-07-15 11:23:24 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-23 12:32:52 +00:00
|
|
|
return MENU_OK;
|
2002-07-15 11:23:24 +00:00
|
|
|
}
|
|
|
|
#else
|
2002-08-23 12:32:52 +00:00
|
|
|
Menu 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);
|
|
|
|
|
|
|
|
sleep(HZ/5);
|
|
|
|
|
|
|
|
button = button_get(false);
|
|
|
|
|
|
|
|
switch(button)
|
|
|
|
{
|
2002-08-10 08:52:11 +00:00
|
|
|
case BUTTON_STOP:
|
2002-08-23 12:32:52 +00:00
|
|
|
return MENU_OK;
|
2002-08-10 08:52:11 +00:00
|
|
|
|
|
|
|
case BUTTON_LEFT:
|
|
|
|
currval--;
|
|
|
|
if(currval < 0)
|
2002-08-14 08:04:42 +00:00
|
|
|
currval = 10;
|
2002-08-10 08:52:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BUTTON_RIGHT:
|
|
|
|
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-08-23 12:32:52 +00:00
|
|
|
return MENU_OK;
|
2002-07-15 11:23:24 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_RTC
|
|
|
|
/* Read RTC RAM contents and display them */
|
2002-08-23 12:32:52 +00:00
|
|
|
Menu 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();
|
|
|
|
sleep(HZ/2);
|
|
|
|
|
|
|
|
button = button_get(false);
|
|
|
|
|
|
|
|
switch(button)
|
|
|
|
{
|
2002-08-10 08:52:11 +00:00
|
|
|
case BUTTON_DOWN:
|
|
|
|
if (addr < 63-16) { addr += 16; }
|
|
|
|
break;
|
|
|
|
case BUTTON_UP:
|
|
|
|
if (addr) { addr -= 16; }
|
|
|
|
break;
|
|
|
|
case BUTTON_F2:
|
|
|
|
/* clear the user RAM space */
|
|
|
|
for (c = 0; c <= 43; c++)
|
2002-08-20 08:43:03 +00:00
|
|
|
rtc_write(0x14 + c, 0);
|
2002-08-10 08:52:11 +00:00
|
|
|
break;
|
|
|
|
case BUTTON_OFF:
|
|
|
|
case BUTTON_LEFT:
|
2002-08-23 12:32:52 +00:00
|
|
|
return MENU_OK;
|
2002-07-15 11:23:24 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-23 12:32:52 +00:00
|
|
|
return MENU_OK;
|
2002-07-15 11:23:24 +00:00
|
|
|
}
|
|
|
|
#else
|
2002-08-23 12:32:52 +00:00
|
|
|
Menu dbg_rtc(void)
|
2002-07-15 11:23:24 +00:00
|
|
|
{
|
2002-08-23 12:32:52 +00:00
|
|
|
return MENU_OK;
|
2002-07-15 11:23:24 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
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-08-23 12:32:52 +00:00
|
|
|
Menu 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();
|
|
|
|
sleep(HZ/16);
|
|
|
|
|
2002-07-23 15:14:02 +00:00
|
|
|
switch(button_get(false))
|
2002-07-22 16:39:17 +00:00
|
|
|
{
|
2002-07-23 15:14:02 +00:00
|
|
|
#ifdef HAVE_RECORDER_KEYPAD
|
2002-08-10 08:52:11 +00:00
|
|
|
case BUTTON_DOWN:
|
2002-07-23 15:14:02 +00:00
|
|
|
#else
|
2002-08-10 08:52:11 +00:00
|
|
|
case BUTTON_RIGHT:
|
2002-07-23 15:14:02 +00:00
|
|
|
#endif
|
2002-08-10 08:52:11 +00:00
|
|
|
addr += NUMROWS;
|
|
|
|
break;
|
2002-07-23 15:14:02 +00:00
|
|
|
#ifdef HAVE_RECORDER_KEYPAD
|
2002-08-10 08:52:11 +00:00
|
|
|
case BUTTON_UP:
|
2002-07-23 15:14:02 +00:00
|
|
|
#else
|
2002-08-10 08:52:11 +00:00
|
|
|
case BUTTON_LEFT:
|
2002-07-23 15:14:02 +00:00
|
|
|
#endif
|
2002-08-10 08:52:11 +00:00
|
|
|
if(addr)
|
|
|
|
addr -= NUMROWS;
|
|
|
|
break;
|
2002-07-23 15:14:02 +00:00
|
|
|
#ifdef HAVE_RECORDER_KEYPAD
|
2002-08-10 08:52:11 +00:00
|
|
|
case BUTTON_LEFT:
|
2002-07-23 15:14:02 +00:00
|
|
|
#else
|
2002-08-10 08:52:11 +00:00
|
|
|
case BUTTON_DOWN:
|
2002-07-23 15:14:02 +00:00
|
|
|
#endif
|
2002-08-23 12:32:52 +00:00
|
|
|
return MENU_OK;
|
2002-07-22 16:39:17 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-23 12:32:52 +00:00
|
|
|
return MENU_OK;
|
2002-07-22 16:39:17 +00:00
|
|
|
}
|
|
|
|
|
2002-08-08 20:44:25 +00:00
|
|
|
#ifdef HAVE_MAS3587F
|
2002-08-23 12:32:52 +00:00
|
|
|
Menu 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();
|
|
|
|
sleep(HZ/16);
|
|
|
|
|
2002-07-23 15:14:02 +00:00
|
|
|
switch(button_get(false))
|
2002-07-22 16:39:17 +00:00
|
|
|
{
|
2002-08-10 08:52:11 +00:00
|
|
|
case BUTTON_DOWN:
|
|
|
|
addr += 4;
|
|
|
|
break;
|
|
|
|
case BUTTON_UP:
|
|
|
|
if (addr) { addr -= 4; }
|
|
|
|
break;
|
|
|
|
case BUTTON_LEFT:
|
2002-08-23 12:32:52 +00:00
|
|
|
return MENU_OK;
|
2002-07-22 16:39:17 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-23 12:32:52 +00:00
|
|
|
return MENU_OK;
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define BAT_FIRST_VAL MAX(POWER_HISTORY_LEN - LCD_WIDTH - 1, 0)
|
|
|
|
#define BAT_YSPACE (LCD_HEIGHT - 20)
|
|
|
|
|
2002-08-23 12:32:52 +00:00
|
|
|
Menu view_battery(void)
|
2002-08-06 10:52:51 +00:00
|
|
|
{
|
|
|
|
int view = 0;
|
|
|
|
int i, x, y;
|
|
|
|
int maxv, minv;
|
|
|
|
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 */
|
|
|
|
maxv = minv = 0;
|
|
|
|
for (i = BAT_FIRST_VAL; i < POWER_HISTORY_LEN; i++) {
|
|
|
|
if (power_history[i] > maxv)
|
|
|
|
maxv = power_history[i];
|
|
|
|
if ((minv == 0) || ((power_history[i]) &&
|
|
|
|
(power_history[i] < minv)) )
|
|
|
|
{
|
|
|
|
minv = power_history[i];
|
|
|
|
}
|
2002-08-06 10:52:51 +00:00
|
|
|
}
|
|
|
|
|
2002-08-10 08:57:47 +00:00
|
|
|
if (minv < 1)
|
|
|
|
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();
|
|
|
|
lcd_puts(0, 0, "Battery voltage:");
|
|
|
|
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;
|
|
|
|
for (i = BAT_FIRST_VAL+1; i < POWER_HISTORY_LEN; i++) {
|
|
|
|
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);
|
|
|
|
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);
|
|
|
|
snprintf(buf, 30, "Charger: %s",
|
|
|
|
charger_inserted() ? "present" : "absent");
|
|
|
|
lcd_puts(0, 3, buf);
|
2002-08-06 10:52:51 +00:00
|
|
|
#ifdef HAVE_CHARGE_CTRL
|
2002-08-10 08:57:47 +00:00
|
|
|
snprintf(buf, 30, "Charging: %s",
|
|
|
|
charger_enabled ? "yes" : "no");
|
|
|
|
lcd_puts(0, 4, buf);
|
2002-08-06 10:52:51 +00:00
|
|
|
#endif
|
2002-08-12 12:21:22 +00:00
|
|
|
y = ( power_history[POWER_HISTORY_LEN-1] * 100
|
2002-08-20 13:38:14 +00:00
|
|
|
+ power_history[POWER_HISTORY_LEN-2] * 100
|
|
|
|
- power_history[POWER_HISTORY_LEN-1-CHARGE_END_NEGD+1] * 100
|
2002-08-12 12:21:22 +00:00
|
|
|
- power_history[POWER_HISTORY_LEN-1-CHARGE_END_NEGD] * 100 )
|
2002-08-20 13:38:14 +00:00
|
|
|
/ CHARGE_END_NEGD / 2;
|
2002-08-06 10:52:51 +00:00
|
|
|
|
2002-08-10 08:57:47 +00:00
|
|
|
snprintf(buf, 30, "short delta: %d", y);
|
|
|
|
lcd_puts(0, 5, buf);
|
2002-08-06 10:52:51 +00:00
|
|
|
|
2002-08-12 12:21:22 +00:00
|
|
|
y = ( power_history[POWER_HISTORY_LEN-1] * 100
|
2002-08-20 13:38:14 +00:00
|
|
|
+ power_history[POWER_HISTORY_LEN-2] * 100
|
|
|
|
- power_history[POWER_HISTORY_LEN-1-CHARGE_END_ZEROD+1] * 100
|
2002-08-12 12:21:22 +00:00
|
|
|
- power_history[POWER_HISTORY_LEN-1-CHARGE_END_ZEROD] * 100 )
|
2002-08-20 13:38:14 +00:00
|
|
|
/ CHARGE_END_ZEROD / 2;
|
2002-08-06 10:52:51 +00:00
|
|
|
|
2002-08-10 08:57:47 +00:00
|
|
|
snprintf(buf, 30, "long delta: %d", y);
|
|
|
|
lcd_puts(0, 6, buf);
|
2002-08-06 10:52:51 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CHARGE_CTRL
|
2002-08-10 08:57:47 +00:00
|
|
|
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++) {
|
|
|
|
y = power_history[POWER_HISTORY_LEN-1-i] -
|
|
|
|
power_history[POWER_HISTORY_LEN-1-i-1];
|
|
|
|
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-08-06 10:52:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
lcd_update();
|
|
|
|
sleep(HZ/2);
|
2002-08-12 12:21:22 +00:00
|
|
|
|
2002-08-06 10:52:51 +00:00
|
|
|
switch(button_get(false))
|
|
|
|
{
|
2002-08-10 08:57:47 +00:00
|
|
|
case BUTTON_UP:
|
|
|
|
if (view)
|
|
|
|
view--;
|
|
|
|
break;
|
2002-08-06 10:52:51 +00:00
|
|
|
|
2002-08-10 08:57:47 +00:00
|
|
|
case BUTTON_DOWN:
|
|
|
|
if (view < 2)
|
|
|
|
view++;
|
|
|
|
break;
|
2002-08-06 10:52:51 +00:00
|
|
|
|
2002-08-10 08:57:47 +00:00
|
|
|
case BUTTON_LEFT:
|
|
|
|
case BUTTON_OFF:
|
2002-08-23 12:32:52 +00:00
|
|
|
return MENU_OK;
|
2002-08-06 10:52:51 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-23 12:32:52 +00:00
|
|
|
return MENU_OK;
|
2002-08-06 10:52:51 +00:00
|
|
|
}
|
|
|
|
|
2002-07-22 16:39:17 +00:00
|
|
|
#endif
|
|
|
|
|
2002-08-14 08:04:42 +00:00
|
|
|
#ifdef HAVE_MAS3507D
|
2002-08-23 12:32:52 +00:00
|
|
|
Menu 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)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
mas_readmem(MAS_BANK_D1, 0xff7, &val, 1);
|
|
|
|
lcd_puts(0, 0, "Design Code");
|
|
|
|
snprintf(buf, 32, "%05x ", val);
|
|
|
|
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:
|
|
|
|
mas_readmem(MAS_BANK_D0, 0x300, &val, 1);
|
|
|
|
lcd_puts(0, 0, "Frame Count");
|
|
|
|
snprintf(buf, 32, "0/300: %04x", val & 0xffff);
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
mas_readmem(MAS_BANK_D0, 0x301, &val, 1);
|
|
|
|
lcd_puts(0, 0, "Status1 ");
|
|
|
|
snprintf(buf, 32, "0/301: %04x", val & 0xffff);
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
mas_readmem(MAS_BANK_D0, 0x302, &val, 1);
|
|
|
|
lcd_puts(0, 0, "Status2 ");
|
|
|
|
snprintf(buf, 32, "0/302: %04x", val & 0xffff);
|
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
mas_readmem(MAS_BANK_D0, 0x303, &val, 1);
|
|
|
|
lcd_puts(0, 0, "CRC Count ");
|
|
|
|
snprintf(buf, 32, "0/303: %04x", val & 0xffff);
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
mas_readmem(MAS_BANK_D0, 0x36d, &val, 1);
|
|
|
|
lcd_puts(0, 0, "PLLOffset48");
|
|
|
|
snprintf(buf, 32, "0/36d %05x", val & 0xfffff);
|
|
|
|
break;
|
|
|
|
case 13:
|
|
|
|
mas_readmem(MAS_BANK_D0, 0x32d, &val, 1);
|
|
|
|
lcd_puts(0, 0, "PLLOffset48");
|
|
|
|
snprintf(buf, 32, "0/32d %05x", val & 0xfffff);
|
|
|
|
break;
|
|
|
|
case 14:
|
|
|
|
mas_readmem(MAS_BANK_D0, 0x36e, &val, 1);
|
|
|
|
lcd_puts(0, 0, "PLLOffset44");
|
|
|
|
snprintf(buf, 32, "0/36e %05x", val & 0xfffff);
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
mas_readmem(MAS_BANK_D0, 0x32e, &val, 1);
|
|
|
|
lcd_puts(0, 0, "PLLOffset44");
|
|
|
|
snprintf(buf, 32, "0/32e %05x", val & 0xfffff);
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
mas_readmem(MAS_BANK_D0, 0x36f, &val, 1);
|
|
|
|
lcd_puts(0, 0, "OutputConf ");
|
|
|
|
snprintf(buf, 32, "0/36f %05x", val & 0xfffff);
|
|
|
|
break;
|
|
|
|
case 17:
|
|
|
|
mas_readmem(MAS_BANK_D0, 0x32f, &val, 1);
|
|
|
|
lcd_puts(0, 0, "OutputConf ");
|
|
|
|
snprintf(buf, 32, "0/32f %05x", val & 0xfffff);
|
|
|
|
break;
|
|
|
|
case 18:
|
|
|
|
mas_readmem(MAS_BANK_D1, 0x7f8, &val, 1);
|
|
|
|
lcd_puts(0, 0, "LL Gain ");
|
|
|
|
snprintf(buf, 32, "1/7f8 %05x", val & 0xfffff);
|
|
|
|
break;
|
|
|
|
case 19:
|
|
|
|
mas_readmem(MAS_BANK_D1, 0x7f9, &val, 1);
|
|
|
|
lcd_puts(0, 0, "LR Gain ");
|
|
|
|
snprintf(buf, 32, "1/7f9 %05x", val & 0xfffff);
|
|
|
|
break;
|
|
|
|
case 20:
|
|
|
|
mas_readmem(MAS_BANK_D1, 0x7fa, &val, 1);
|
|
|
|
lcd_puts(0, 0, "RL Gain ");
|
|
|
|
snprintf(buf, 32, "1/7fa %05x", val & 0xfffff);
|
|
|
|
break;
|
|
|
|
case 21:
|
|
|
|
mas_readmem(MAS_BANK_D1, 0x7fb, &val, 1);
|
|
|
|
lcd_puts(0, 0, "RR Gain ");
|
|
|
|
snprintf(buf, 32, "1/7fb %05x", val & 0xfffff);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
lcd_puts(0, 1, buf);
|
|
|
|
|
|
|
|
button = button_get_w_tmo(HZ/5);
|
|
|
|
switch(button)
|
|
|
|
{
|
|
|
|
case BUTTON_STOP:
|
2002-08-23 12:32:52 +00:00
|
|
|
return MENU_OK;
|
2002-08-14 08:04:42 +00:00
|
|
|
|
|
|
|
case BUTTON_LEFT:
|
|
|
|
currval--;
|
|
|
|
if(currval < 0)
|
|
|
|
currval = 23;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BUTTON_RIGHT:
|
|
|
|
currval++;
|
|
|
|
if(currval > 23)
|
|
|
|
currval = 0;
|
|
|
|
break;
|
|
|
|
case BUTTON_PLAY:
|
|
|
|
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-23 12:32:52 +00:00
|
|
|
return MENU_OK;
|
2002-08-14 08:04:42 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-08-23 12:32:52 +00:00
|
|
|
Menu debug_menu(void)
|
2002-07-15 11:23:24 +00:00
|
|
|
{
|
|
|
|
int m;
|
2002-08-23 12:32:52 +00:00
|
|
|
Menu result;
|
2002-07-15 11:23:24 +00:00
|
|
|
|
|
|
|
struct menu_items items[] = {
|
2002-07-22 16:39:17 +00:00
|
|
|
{ "View I/O ports", dbg_ports },
|
2002-07-15 22:25:45 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-07-15 11:23:24 +00:00
|
|
|
#ifdef HAVE_RTC
|
2002-07-22 16:39:17 +00:00
|
|
|
{ "View/clr RTC RAM", dbg_rtc },
|
2002-07-15 11:23:24 +00:00
|
|
|
#endif /* HAVE_RTC */
|
|
|
|
#endif /* HAVE_LCD_BITMAP */
|
2002-07-22 16:39:17 +00:00
|
|
|
{ "View OS stacks", dbg_os },
|
2002-08-14 08:04:42 +00:00
|
|
|
#ifdef HAVE_MAS3507D
|
|
|
|
{ "View MAS info", dbg_mas_info },
|
|
|
|
#endif
|
2002-07-22 16:39:17 +00:00
|
|
|
{ "View MAS regs", dbg_mas },
|
2002-08-08 20:44:25 +00:00
|
|
|
#ifdef HAVE_MAS3587F
|
2002-07-22 16:39:17 +00:00
|
|
|
{ "View MAS codec", dbg_mas_codec },
|
2002-08-08 20:44:25 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-08-06 10:52:51 +00:00
|
|
|
{ "View battery", view_battery },
|
2002-07-22 16:39:17 +00:00
|
|
|
#endif
|
2002-07-15 11:23:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
m=menu_init( items, sizeof items / sizeof(struct menu_items) );
|
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 */
|
|
|
|
|