TMS320DM320: Add generic I/O debug window for targets other than mrobe 500.

DEBUG_GIO allows users to set any GIO options (direction, output state). As this feature should be used only by experienced users it is compiled conditionally.

Raise I2C delay values since udelay() is now precise and previous values seems to be too low for some devices.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31421 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Tomasz Moń 2011-12-24 14:18:53 +00:00
parent 616d7869e9
commit 4539ffe1f3
2 changed files with 170 additions and 12 deletions

View file

@ -7,6 +7,7 @@
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* $Id$ * $Id$
* *
* Copyright (C) 2011 by Tomasz Moń
* Copyright (C) 2007, 2009 by Karl Kurbjun * Copyright (C) 2007, 2009 by Karl Kurbjun
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -36,25 +37,134 @@
#include "m66591.h" #include "m66591.h"
#endif #endif
/* define only if you know what you are doing */
#undef DEBUG_GIO
#ifdef DEBUG_GIO
#ifdef SANSA_CONNECT
#define DEBUG_GIO_SET BUTTON_UP
#define DEBUG_GIO_SET_TXT "UP"
#define DEBUG_GIO_CLR BUTTON_DOWN
#define DEBUG_GIO_CLR_TXT "DOWN"
#define DEBUG_GIO_TOGGLE BUTTON_SELECT
#define DEBUG_GIO_TOGGLE_TXT "SELECT"
#define DEBUG_GIO_NEXT BUTTON_SCROLL_FWD
#define DEBUG_GIO_PREV BUTTON_SCROLL_BACK
#else
#warning "No keymap defined for target"
#endif
static void gio_set(int gio)
{
if (gio < 0)
return;
if (gio <= 15)
IO_GIO_BITSET0 = (1 << gio);
else if (gio <= 31)
IO_GIO_BITSET1 = (1 << (gio-16));
else if (gio <= 40)
IO_GIO_BITSET2 = (1 << (gio-32));
}
static void gio_clear(int gio)
{
if (gio < 0)
return;
if (gio <= 15)
IO_GIO_BITCLR0 = (1 << gio);
else if (gio <= 31)
IO_GIO_BITCLR1 = (1 << (gio-16));
else if (gio <= 40)
IO_GIO_BITCLR2 = (1 << (gio-32));
}
static void gio_toggle_direction(int gio)
{
if (gio < 0)
return;
if (gio <= 15)
IO_GIO_DIR0 ^= (1 << gio);
else if (gio <= 31)
IO_GIO_DIR1 ^= (1 << (gio-16));
else if (gio <= 40)
IO_GIO_DIR2 ^= (1 << (gio-32));
}
static bool gio_is_inverted(int gio)
{
unsigned short reg;
int bit;
if (gio <= 15)
reg = IO_GIO_INV0, bit = (1 << gio);
else if (gio <= 31)
reg = IO_GIO_INV1, bit = (1 << (gio-16));
else if (gio <= 40)
reg = IO_GIO_INV2, bit = (1 << (gio-32));
return reg & bit;
}
static bool gio_is_output(int gio)
{
unsigned short reg;
int bit;
if (gio <= 15)
reg = IO_GIO_DIR0, bit = (1 << gio);
else if (gio <= 31)
reg = IO_GIO_DIR1, bit = (1 << (gio-16));
else if (gio <= 40)
reg = IO_GIO_DIR2, bit = (1 << (gio-32));
return !(reg & bit);
}
static bool gio_get_state(int gio)
{
unsigned short reg;
int bit;
if (gio <= 15)
reg = IO_GIO_BITSET0, bit = (1 << gio);
else if (gio <= 31)
reg = IO_GIO_BITSET1, bit = (1 << (gio-16));
else if (gio <= 40)
reg = IO_GIO_BITSET2, bit = (1 << (gio-32));
return reg & bit;
}
#endif
bool dbg_ports(void) bool dbg_ports(void)
{ {
#if defined(MROBE_500)
int line = 0; int line = 0;
int i; int i;
int button; int button;
bool done=false; bool done=false;
#ifdef DEBUG_GIO
int gio = 0;
#endif
(void)i;
lcd_setfont(FONT_SYSFIXED); lcd_setfont(FONT_SYSFIXED);
lcd_clear_display(); lcd_clear_display();
while(!done) while(!done)
{ {
line = 0; line = 0;
button = button_get(false); button = button_get_w_tmo(1);
button&=~BUTTON_REPEAT;
if (button == BUTTON_POWER) if (button == BUTTON_POWER)
done=true; done=true;
#if defined(MROBE_500)
lcd_puts(0, line++, "[USB Information]"); lcd_puts(0, line++, "[USB Information]");
lcd_putsf(0, line++, "TRN_CTRL: 0x%04x TRN_LNSTAT: 0x%04x", lcd_putsf(0, line++, "TRN_CTRL: 0x%04x TRN_LNSTAT: 0x%04x",
@ -114,10 +224,58 @@ bool dbg_ports(void)
lcd_putsf(0, line++, "EMIF_CS4CTRL1:0x%04x EMIF_CS4CTRL2:0x%04x", lcd_putsf(0, line++, "EMIF_CS4CTRL1:0x%04x EMIF_CS4CTRL2:0x%04x",
IO_EMIF_CS4CTRL1, IO_EMIF_CS4CTRL2); IO_EMIF_CS4CTRL1, IO_EMIF_CS4CTRL2);
#elif !defined(DEBUG_GIO)
lcd_putsf(0, line++, "/* GIO0 - GIO15 */");
lcd_putsf(0, line++, "GIO_DIR0: 0x%04X", IO_GIO_DIR0);
lcd_putsf(0, line++, "GIO_INV0: 0x%04X", IO_GIO_INV0);
lcd_putsf(0, line++, "GIO_BITSET0: 0x%04X", IO_GIO_BITSET0);
lcd_putsf(0, line++, "/* GIO16 - GIO31 */");
lcd_putsf(0, line++, "GIO_DIR1: 0x%04X", IO_GIO_DIR1);
lcd_putsf(0, line++, "GIO_INV1: 0x%04X", IO_GIO_INV1);
lcd_putsf(0, line++, "GIO_BITSET1: 0x%04X", IO_GIO_BITSET1);
lcd_putsf(0, line++, "/* GIO32 - GIO40 */");
lcd_putsf(0, line++, "GIO_DIR2: 0x%04X", IO_GIO_DIR2);
lcd_putsf(0, line++, "GIO_INV2: 0x%04X", IO_GIO_INV2);
lcd_putsf(0, line++, "GIO_BITSET2: 0x%04X", IO_GIO_BITSET2);
#endif
#ifdef DEBUG_GIO
if ((button == DEBUG_GIO_NEXT) && (gio < 40))
gio++;
else if ((button == DEBUG_GIO_PREV) && (gio > 0))
gio--;
else if (button == DEBUG_GIO_SET)
gio_set(gio);
else if (button == DEBUG_GIO_CLR)
gio_clear(gio);
else if (button == DEBUG_GIO_TOGGL
#if 0
/*
* this makes current consumption pretty constant
* at cost of screen updates
*/
else
continue;
#endif
line++;
lcd_putsf(0, line++, "< GIO%d >", gio);
lcd_putsf(0, line++, "GIO%d is %d (%s, %s)",
gio,
gio_get_state(gio) ? 1 : 0,
gio_is_inverted(gio) ? "inverted" : "normal",
gio_is_output(gio) ? "output" : "input");
lcd_putsf(0, line++, "%s - Set bit (using INV)", DEBUG_GIO_SET_TXT);
lcd_putsf(0, line++, "%s - Clear bit (using INV)",
DEBUG_GIO_CLR_TXT);
lcd_putsf(0, line++, "%s - toggle direction",DEBUG_GIO_TOGGLE_TXT);
#endif
lcd_update(); lcd_update();
} }
#endif
return false; return false;
} }
@ -209,7 +367,7 @@ bool dbg_hw_info(void)
else if (button==BUTTON_RC_REW) else if (button==BUTTON_RC_REW)
address-=0x800; address-=0x800;
#else #else
button = button_get(false); button = button_get_w_tmo(1);
if(button & BUTTON_POWER) if(button & BUTTON_POWER)
done = true; done = true;
#if defined(CREATIVE_ZVx) #if defined(CREATIVE_ZVx)

View file

@ -258,12 +258,12 @@ static const struct i2c_interface dm320_i2c_interface = {
.delay = dm320_i2c_delay, .delay = dm320_i2c_delay,
/* uncalibrated */ /* uncalibrated */
.delay_hd_sta = 1, .delay_hd_sta = 2,
.delay_hd_dat = 1, .delay_hd_dat = 2,
.delay_su_dat = 1, .delay_su_dat = 2,
.delay_su_sto = 1, .delay_su_sto = 2,
.delay_su_sta = 1, .delay_su_sta = 2,
.delay_thigh = 1 .delay_thigh = 2
}; };
void i2c_init(void) void i2c_init(void)