summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Moń <desowin@gmail.com>2011-12-24 14:18:53 +0000
committerTomasz Moń <desowin@gmail.com>2011-12-24 14:18:53 +0000
commit4539ffe1f384ddc9b3b5eecf95fbd33ece3d4f2e (patch)
tree643c72c339f0499c42bf315c26a58e66c86cd118
parent616d7869e9a0b55b83157c3f3085243fecda1586 (diff)
downloadrockbox-4539ffe1f384ddc9b3b5eecf95fbd33ece3d4f2e.zip
rockbox-4539ffe1f384ddc9b3b5eecf95fbd33ece3d4f2e.tar.gz
rockbox-4539ffe1f384ddc9b3b5eecf95fbd33ece3d4f2e.tar.bz2
rockbox-4539ffe1f384ddc9b3b5eecf95fbd33ece3d4f2e.tar.xz
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
-rw-r--r--firmware/target/arm/tms320dm320/debug-dm320.c170
-rw-r--r--firmware/target/arm/tms320dm320/i2c-dm320.c12
2 files changed, 170 insertions, 12 deletions
diff --git a/firmware/target/arm/tms320dm320/debug-dm320.c b/firmware/target/arm/tms320dm320/debug-dm320.c
index 262d843..57b4bc5 100644
--- a/firmware/target/arm/tms320dm320/debug-dm320.c
+++ b/firmware/target/arm/tms320dm320/debug-dm320.c
@@ -7,6 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
+ * Copyright (C) 2011 by Tomasz Moń
* Copyright (C) 2007, 2009 by Karl Kurbjun
*
* This program is free software; you can redistribute it and/or
@@ -36,25 +37,134 @@
#include "m66591.h"
#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)
{
-#if defined(MROBE_500)
int line = 0;
int i;
int button;
bool done=false;
-
+#ifdef DEBUG_GIO
+ int gio = 0;
+#endif
+ (void)i;
+
lcd_setfont(FONT_SYSFIXED);
lcd_clear_display();
while(!done)
{
line = 0;
- button = button_get(false);
- button&=~BUTTON_REPEAT;
+ button = button_get_w_tmo(1);
+
if (button == BUTTON_POWER)
done=true;
+#if defined(MROBE_500)
lcd_puts(0, line++, "[USB Information]");
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",
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();
}
-#endif
+
return false;
}
@@ -209,7 +367,7 @@ bool dbg_hw_info(void)
else if (button==BUTTON_RC_REW)
address-=0x800;
#else
- button = button_get(false);
+ button = button_get_w_tmo(1);
if(button & BUTTON_POWER)
done = true;
#if defined(CREATIVE_ZVx)
diff --git a/firmware/target/arm/tms320dm320/i2c-dm320.c b/firmware/target/arm/tms320dm320/i2c-dm320.c
index 2530209..c201019 100644
--- a/firmware/target/arm/tms320dm320/i2c-dm320.c
+++ b/firmware/target/arm/tms320dm320/i2c-dm320.c
@@ -258,12 +258,12 @@ static const struct i2c_interface dm320_i2c_interface = {
.delay = dm320_i2c_delay,
/* uncalibrated */
- .delay_hd_sta = 1,
- .delay_hd_dat = 1,
- .delay_su_dat = 1,
- .delay_su_sto = 1,
- .delay_su_sta = 1,
- .delay_thigh = 1
+ .delay_hd_sta = 2,
+ .delay_hd_dat = 2,
+ .delay_su_dat = 2,
+ .delay_su_sto = 2,
+ .delay_su_sta = 2,
+ .delay_thigh = 2
};
void i2c_init(void)