summaryrefslogtreecommitdiff
path: root/firmware/target/arm
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm')
-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 262d843bfc..57b4bc5982 100644
--- a/firmware/target/arm/tms320dm320/debug-dm320.c
+++ b/firmware/target/arm/tms320dm320/debug-dm320.c
@@ -7,6 +7,7 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Copyright (C) 2011 by Tomasz Moń
10 * Copyright (C) 2007, 2009 by Karl Kurbjun 11 * Copyright (C) 2007, 2009 by Karl Kurbjun
11 * 12 *
12 * This program is free software; you can redistribute it and/or 13 * This program is free software; you can redistribute it and/or
@@ -36,25 +37,134 @@
36#include "m66591.h" 37#include "m66591.h"
37#endif 38#endif
38 39
40/* define only if you know what you are doing */
41#undef DEBUG_GIO
42
43#ifdef DEBUG_GIO
44#ifdef SANSA_CONNECT
45 #define DEBUG_GIO_SET BUTTON_UP
46 #define DEBUG_GIO_SET_TXT "UP"
47
48 #define DEBUG_GIO_CLR BUTTON_DOWN
49 #define DEBUG_GIO_CLR_TXT "DOWN"
50
51 #define DEBUG_GIO_TOGGLE BUTTON_SELECT
52 #define DEBUG_GIO_TOGGLE_TXT "SELECT"
53
54 #define DEBUG_GIO_NEXT BUTTON_SCROLL_FWD
55 #define DEBUG_GIO_PREV BUTTON_SCROLL_BACK
56#else
57 #warning "No keymap defined for target"
58#endif
59
60static void gio_set(int gio)
61{
62 if (gio < 0)
63 return;
64
65 if (gio <= 15)
66 IO_GIO_BITSET0 = (1 << gio);
67 else if (gio <= 31)
68 IO_GIO_BITSET1 = (1 << (gio-16));
69 else if (gio <= 40)
70 IO_GIO_BITSET2 = (1 << (gio-32));
71}
72
73static void gio_clear(int gio)
74{
75 if (gio < 0)
76 return;
77
78 if (gio <= 15)
79 IO_GIO_BITCLR0 = (1 << gio);
80 else if (gio <= 31)
81 IO_GIO_BITCLR1 = (1 << (gio-16));
82 else if (gio <= 40)
83 IO_GIO_BITCLR2 = (1 << (gio-32));
84}
85
86static void gio_toggle_direction(int gio)
87{
88 if (gio < 0)
89 return;
90
91 if (gio <= 15)
92 IO_GIO_DIR0 ^= (1 << gio);
93 else if (gio <= 31)
94 IO_GIO_DIR1 ^= (1 << (gio-16));
95 else if (gio <= 40)
96 IO_GIO_DIR2 ^= (1 << (gio-32));
97}
98
99static bool gio_is_inverted(int gio)
100{
101 unsigned short reg;
102 int bit;
103
104 if (gio <= 15)
105 reg = IO_GIO_INV0, bit = (1 << gio);
106 else if (gio <= 31)
107 reg = IO_GIO_INV1, bit = (1 << (gio-16));
108 else if (gio <= 40)
109 reg = IO_GIO_INV2, bit = (1 << (gio-32));
110
111 return reg & bit;
112}
113
114static bool gio_is_output(int gio)
115{
116 unsigned short reg;
117 int bit;
118
119 if (gio <= 15)
120 reg = IO_GIO_DIR0, bit = (1 << gio);
121 else if (gio <= 31)
122 reg = IO_GIO_DIR1, bit = (1 << (gio-16));
123 else if (gio <= 40)
124 reg = IO_GIO_DIR2, bit = (1 << (gio-32));
125
126 return !(reg & bit);
127}
128
129static bool gio_get_state(int gio)
130{
131 unsigned short reg;
132 int bit;
133
134 if (gio <= 15)
135 reg = IO_GIO_BITSET0, bit = (1 << gio);
136 else if (gio <= 31)
137 reg = IO_GIO_BITSET1, bit = (1 << (gio-16));
138 else if (gio <= 40)
139 reg = IO_GIO_BITSET2, bit = (1 << (gio-32));
140
141 return reg & bit;
142}
143#endif
144
39bool dbg_ports(void) 145bool dbg_ports(void)
40{ 146{
41#if defined(MROBE_500)
42 int line = 0; 147 int line = 0;
43 int i; 148 int i;
44 int button; 149 int button;
45 bool done=false; 150 bool done=false;
46 151#ifdef DEBUG_GIO
152 int gio = 0;
153#endif
154 (void)i;
155
47 lcd_setfont(FONT_SYSFIXED); 156 lcd_setfont(FONT_SYSFIXED);
48 lcd_clear_display(); 157 lcd_clear_display();
49 158
50 while(!done) 159 while(!done)
51 { 160 {
52 line = 0; 161 line = 0;
53 button = button_get(false); 162 button = button_get_w_tmo(1);
54 button&=~BUTTON_REPEAT; 163
55 if (button == BUTTON_POWER) 164 if (button == BUTTON_POWER)
56 done=true; 165 done=true;
57 166
167#if defined(MROBE_500)
58 lcd_puts(0, line++, "[USB Information]"); 168 lcd_puts(0, line++, "[USB Information]");
59 169
60 lcd_putsf(0, line++, "TRN_CTRL: 0x%04x TRN_LNSTAT: 0x%04x", 170 lcd_putsf(0, line++, "TRN_CTRL: 0x%04x TRN_LNSTAT: 0x%04x",
@@ -114,10 +224,58 @@ bool dbg_ports(void)
114 224
115 lcd_putsf(0, line++, "EMIF_CS4CTRL1:0x%04x EMIF_CS4CTRL2:0x%04x", 225 lcd_putsf(0, line++, "EMIF_CS4CTRL1:0x%04x EMIF_CS4CTRL2:0x%04x",
116 IO_EMIF_CS4CTRL1, IO_EMIF_CS4CTRL2); 226 IO_EMIF_CS4CTRL1, IO_EMIF_CS4CTRL2);
227#elif !defined(DEBUG_GIO)
228 lcd_putsf(0, line++, "/* GIO0 - GIO15 */");
229 lcd_putsf(0, line++, "GIO_DIR0: 0x%04X", IO_GIO_DIR0);
230 lcd_putsf(0, line++, "GIO_INV0: 0x%04X", IO_GIO_INV0);
231 lcd_putsf(0, line++, "GIO_BITSET0: 0x%04X", IO_GIO_BITSET0);
232
233 lcd_putsf(0, line++, "/* GIO16 - GIO31 */");
234 lcd_putsf(0, line++, "GIO_DIR1: 0x%04X", IO_GIO_DIR1);
235 lcd_putsf(0, line++, "GIO_INV1: 0x%04X", IO_GIO_INV1);
236 lcd_putsf(0, line++, "GIO_BITSET1: 0x%04X", IO_GIO_BITSET1);
237
238 lcd_putsf(0, line++, "/* GIO32 - GIO40 */");
239 lcd_putsf(0, line++, "GIO_DIR2: 0x%04X", IO_GIO_DIR2);
240 lcd_putsf(0, line++, "GIO_INV2: 0x%04X", IO_GIO_INV2);
241 lcd_putsf(0, line++, "GIO_BITSET2: 0x%04X", IO_GIO_BITSET2);
242#endif
243
244#ifdef DEBUG_GIO
245 if ((button == DEBUG_GIO_NEXT) && (gio < 40))
246 gio++;
247 else if ((button == DEBUG_GIO_PREV) && (gio > 0))
248 gio--;
249 else if (button == DEBUG_GIO_SET)
250 gio_set(gio);
251 else if (button == DEBUG_GIO_CLR)
252 gio_clear(gio);
253 else if (button == DEBUG_GIO_TOGGL
254#if 0
255 /*
256 * this makes current consumption pretty constant
257 * at cost of screen updates
258 */
259 else
260 continue;
261#endif
262
263 line++;
264 lcd_putsf(0, line++, "< GIO%d >", gio);
265 lcd_putsf(0, line++, "GIO%d is %d (%s, %s)",
266 gio,
267 gio_get_state(gio) ? 1 : 0,
268 gio_is_inverted(gio) ? "inverted" : "normal",
269 gio_is_output(gio) ? "output" : "input");
270 lcd_putsf(0, line++, "%s - Set bit (using INV)", DEBUG_GIO_SET_TXT);
271 lcd_putsf(0, line++, "%s - Clear bit (using INV)",
272 DEBUG_GIO_CLR_TXT);
273 lcd_putsf(0, line++, "%s - toggle direction",DEBUG_GIO_TOGGLE_TXT);
274#endif
117 275
118 lcd_update(); 276 lcd_update();
119 } 277 }
120#endif 278
121 return false; 279 return false;
122} 280}
123 281
@@ -209,7 +367,7 @@ bool dbg_hw_info(void)
209 else if (button==BUTTON_RC_REW) 367 else if (button==BUTTON_RC_REW)
210 address-=0x800; 368 address-=0x800;
211#else 369#else
212 button = button_get(false); 370 button = button_get_w_tmo(1);
213 if(button & BUTTON_POWER) 371 if(button & BUTTON_POWER)
214 done = true; 372 done = true;
215#if defined(CREATIVE_ZVx) 373#if defined(CREATIVE_ZVx)
diff --git a/firmware/target/arm/tms320dm320/i2c-dm320.c b/firmware/target/arm/tms320dm320/i2c-dm320.c
index 2530209402..c2010199e1 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 = {
258 .delay = dm320_i2c_delay, 258 .delay = dm320_i2c_delay,
259 259
260 /* uncalibrated */ 260 /* uncalibrated */
261 .delay_hd_sta = 1, 261 .delay_hd_sta = 2,
262 .delay_hd_dat = 1, 262 .delay_hd_dat = 2,
263 .delay_su_dat = 1, 263 .delay_su_dat = 2,
264 .delay_su_sto = 1, 264 .delay_su_sto = 2,
265 .delay_su_sta = 1, 265 .delay_su_sta = 2,
266 .delay_thigh = 1 266 .delay_thigh = 2
267}; 267};
268 268
269void i2c_init(void) 269void i2c_init(void)