summaryrefslogtreecommitdiff
path: root/firmware/target/mips
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2020-09-01 03:22:48 -0400
committerWilliam Wilgus <me.theuser@yahoo.com>2020-09-02 16:38:43 +0000
commit35371df671e3677d896fcde516eaec3a899b5d8f (patch)
tree518d601065764b4866aeeeb92f54b1812a53e25c /firmware/target/mips
parentbb6fc21244032fd763159d02639e91390712dec2 (diff)
downloadrockbox-35371df671e3677d896fcde516eaec3a899b5d8f.tar.gz
rockbox-35371df671e3677d896fcde516eaec3a899b5d8f.zip
XduooX3 Debug Menu -- HW_info
add scrolling for clocks and such moved to a switch based structure.. this ends up a lot cleaner Change-Id: I940506c4b8dc73f0b776d20810780527cbf7e0d4
Diffstat (limited to 'firmware/target/mips')
-rw-r--r--firmware/target/mips/ingenic_jz47xx/debug-jz4760.c467
1 files changed, 339 insertions, 128 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c b/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c
index 301f72a12e..567c1798c7 100644
--- a/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c
+++ b/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c
@@ -7,6 +7,7 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * 8 *
9 * Copyright (C) 2018 by Solomon Peachy 9 * Copyright (C) 2018 by Solomon Peachy
10 * Copyright (C) 2020 by William Wilgus
10 * 11 *
11 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License 13 * modify it under the terms of the GNU General Public License
@@ -31,14 +32,19 @@
31 32
32#ifndef BOOTLOADER 33#ifndef BOOTLOADER
33#include "action.h" 34#include "action.h"
35#include "list.h"
34 36
37static bool is_done = false;
35static int line = 0; 38static int line = 0;
39static int maxlines = 0;
36 40
37/* 41/*
38 * Clock Generation Module 42 * Clock Generation Module
39 */ 43 */
40#define TO_MHZ(x) ((x)/1000000), ((x)%1000000)/10000 44#define DBG_FREQ_FMT "%s:%3d.%02d %cHz" /*IDSTR, 000 HZ INT, 00HZ FRAC, _/K/M */
41#define TO_KHZ(x) ((x)/1000), ((x)%1000)/10 45#define TO_MHZ(x) ((x)/1000000), ((x)%1000000)/10000, 'M'
46#define TO_KHZ(x) ((x)/1000), ((x)%1000)/10, 'K'
47
42 48
43#define DEBUG_CANCEL ACTION_STD_CANCEL 49#define DEBUG_CANCEL ACTION_STD_CANCEL
44#define DEBUG_NEXT ACTION_STD_NEXT 50#define DEBUG_NEXT ACTION_STD_NEXT
@@ -50,126 +56,259 @@ static int line = 0;
50 56
51#define ON "Enabled" 57#define ON "Enabled"
52#define OFF "Disabled" 58#define OFF "Disabled"
59#define STOPPED "Stopped"
60#define RUNNING "Running"
53 61
54static bool dbg_btn(bool *done, int *x) 62static bool dbg_btn(bool *done, int *x)
55{ 63{
56 bool cont = !*done; 64 bool cont = !*done;
57 if (cont) 65 if (cont)
58 { 66 {
59 lcd_update();
60 int button = get_action(CONTEXT_STD,HZ/10); 67 int button = get_action(CONTEXT_STD,HZ/10);
61 switch(button) 68 switch(button)
62 { 69 {
63 case DEBUG_CANCEL: 70 case DEBUG_CANCEL:
64 *done = true; 71 *done = true;
72
65 case DEBUG_NEXT: 73 case DEBUG_NEXT:
66 cont = false; 74 cont = false;
67 case DEBUG_LEFT_JUSTIFY: 75 case DEBUG_LEFT_JUSTIFY:
68 (*x) = 0; 76 if (x){(*x) = 0;}
69 sleep(HZ/5); 77 sleep(HZ/5);
70 break; 78 break;
71 case DEBUG_LEFT_SCROLL: 79 case DEBUG_LEFT_SCROLL:
72 (*x)--; 80 if(x){(*x)--;}
81 break;
73 } 82 }
74 } 83 }
84 return cont;
85}
86
87static bool dbg_btn_update(bool *done, int *x)
88{
89 bool cont = !*done;
90 if (cont)
91 {
92 lcd_update();
93 cont = dbg_btn(done, x);
94 }
75 lcd_clear_display(); 95 lcd_clear_display();
76 return cont; 96 return cont;
77} 97}
78 98
79static void display_clocks(void) 99static inline unsigned int read_cp0_15 (void)
100{
101 /* CPUID Cp0 Register 15 Select 0 */
102 unsigned int cp_val;
103 asm volatile("mfc0 %0, $15\n" : "=r" (cp_val));
104 return (cp_val);
105}
106
107static bool display_clocks(void)
80{ 108{
81 unsigned int cppcr0 = REG_CPM_CPPCR0; /* PLL Control Register */ 109 unsigned int cppcr0 = REG_CPM_CPPCR0; /* PLL Control Register */
82 unsigned int cppcr1 = REG_CPM_CPPCR1; /* PLL Control Register */ 110 unsigned int cppcr1 = REG_CPM_CPPCR1; /* PLL Control Register */
83 unsigned int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32}; 111 unsigned int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32};
84 unsigned int od[4] = {1, 2, 4, 8}; 112 unsigned int od[4] = {1, 2, 4, 8};
85 113
86 lcd_putsf(0, line++, "CPPCR0:0x%08x", cppcr0); 114 int x = 0;
87 if (cppcr0 & CPPCR0_PLLEN) { 115 int cur_item = -1;
88 lcd_putsf(0, line++, "PLL0 :%3d.%02d MHz", TO_MHZ(__cpm_get_pllout())); 116 bool is_last_item = false;
89 lcd_putsf(0, line++, "m:n:o :%d:%d:%d", 117
90 __cpm_get_pllm(), 118 while(!is_done)
91 __cpm_get_plln(), 119 {
92 od[__cpm_get_pllod()] 120 lcd_clear_display();
93 ); 121
94 } 122 if (is_last_item || cur_item < 0)
95 lcd_putsf(0, line++, "CPPCR1:0x%08x", cppcr1); 123 cur_item = 0;
96 if (cppcr1 & CPPCR1_PLL1EN) { 124 else if (cur_item >= 0)
97 lcd_putsf(0, line++, "PLL1 :%3d.%02d MHz", TO_MHZ(__cpm_get_pll1out())); 125 cur_item += maxlines;
98 lcd_putsf(0, line++, "m:n:o :%d:%d:%d", 126
99 __cpm_get_pll1m(), 127 is_last_item = false;
100 __cpm_get_pll1n(), 128
101 od[__cpm_get_pll1od()] 129 while(dbg_btn(&is_done, &x))
102 ); 130 {
131 lcd_clear_display();
132 line = 0;
133 switch(cur_item)
134 {
135 case 0:
136 lcd_putsf(x, line++, "[%s]", "Clocks");
137 case 1:
138 lcd_putsf(x, line++, "CPPCR0:0x%08x", cppcr0);
139 case 2:
140 if (cppcr0 & CPPCR0_PLLEN) {
141 lcd_putsf(x, line++, DBG_FREQ_FMT, "PLL0 ",
142 TO_MHZ(__cpm_get_pllout()));
143 lcd_putsf(x, line++, "m:n:o :%d:%d:%d",
144 __cpm_get_pllm(),
145 __cpm_get_plln(),
146 od[__cpm_get_pllod()]
147 );
148 }
149 else if (cur_item == 2)
150 cur_item++;
151 case 3:
152 lcd_putsf(x, line++, "CPPCR1:0x%08x", cppcr1);
153 case 4:
154 if (cppcr1 & CPPCR1_PLL1EN) {
155 lcd_putsf(x, line++, DBG_FREQ_FMT, "PLL1 ",
156 TO_MHZ(__cpm_get_pll1out()));
157 lcd_putsf(x, line++, "m:n:o :%d:%d:%d",
158 __cpm_get_pll1m(),
159 __cpm_get_pll1n(),
160 od[__cpm_get_pll1od()]
161 );
162 }
163 else if (cur_item == 3)
164 cur_item++;
165 case 5:
166 lcd_putsf(x, line++, "C:H:M:P:%d:%d:%d:%d",
167 div[__cpm_get_cdiv()],
168 div[__cpm_get_hdiv()],
169 div[__cpm_get_mdiv()],
170 div[__cpm_get_pdiv()]
171 );
172 case 6:
173 lcd_putsf(x, line++, "I:P:M : %d:%d:%d",
174 __cpm_get_i2sdiv()+1,
175 __cpm_get_pixdiv()+1,
176 __cpm_get_mscdiv()+1
177 );
178 case 7:
179 lcd_putsf(x, line++, DBG_FREQ_FMT, "CCLK ",
180 TO_MHZ(__cpm_get_cclk()));
181 case 8:
182 lcd_putsf(x, line++, DBG_FREQ_FMT, "HCLK ",
183 TO_MHZ(__cpm_get_hclk()));
184 case 9:
185 lcd_putsf(x, line++, DBG_FREQ_FMT, "MCLK ",
186 TO_MHZ(__cpm_get_mclk()));
187 case 10:
188 lcd_putsf(x, line++, DBG_FREQ_FMT, "PCLK ",
189 TO_MHZ(__cpm_get_pclk()));
190 case 11:
191 lcd_putsf(x, line++, DBG_FREQ_FMT, "PIXCLK ",
192 TO_KHZ(__cpm_get_pixclk()));
193 case 12:
194 lcd_putsf(x, line++, DBG_FREQ_FMT, "I2SCLK ",
195 TO_MHZ(__cpm_get_i2sclk()));
196 case 13:
197 lcd_putsf(x, line++, DBG_FREQ_FMT, "MSCCLK ",
198 TO_MHZ(__cpm_get_mscclk()));
199 case 14:
200 lcd_putsf(x, line++, DBG_FREQ_FMT, "XTALCLK ",
201 TO_MHZ(__cpm_get_extalclk()));
202 case 15:
203 lcd_putsf(x, line++, DBG_FREQ_FMT, "RTCCLK ",
204 TO_KHZ(__cpm_get_rtcclk()));
205 default:
206 if (line <= maxlines + 1)
207 is_last_item = true;
208 }
209 lcd_update();
210 }
103 } 211 }
104 lcd_putsf(0, line++, "C:H:M:P:%d:%d:%d:%d", 212 return true;
105 div[__cpm_get_cdiv()],
106 div[__cpm_get_hdiv()],
107 div[__cpm_get_mdiv()],
108 div[__cpm_get_pdiv()]
109 );
110 lcd_putsf(0, line++, "I:P:M : %d:%d:%d",
111 __cpm_get_i2sdiv()+1,
112 __cpm_get_pixdiv()+1,
113 __cpm_get_mscdiv()+1
114 );
115 lcd_putsf(0, line++, "CCLK :%3d.%02d MHz", TO_MHZ(__cpm_get_cclk()));
116 lcd_putsf(0, line++, "HCLK :%3d.%02d MHz", TO_MHZ(__cpm_get_hclk()));
117 lcd_putsf(0, line++, "MCLK :%3d.%02d MHz", TO_MHZ(__cpm_get_mclk()));
118 lcd_putsf(0, line++, "PCLK :%3d.%02d MHz", TO_MHZ(__cpm_get_pclk()));
119 lcd_putsf(0, line++, "PIXCLK:%6d.%02d KHz", TO_KHZ(__cpm_get_pixclk()));
120 lcd_putsf(0, line++, "I2SCLK:%3d.%02d MHz", TO_MHZ(__cpm_get_i2sclk()));
121 lcd_putsf(0, line++, "MSCCLK:%3d.%02d MHz", TO_MHZ(__cpm_get_mscclk()));
122 lcd_putsf(0, line++, "EXTALCLK:%3d.%02d MHz", TO_MHZ(__cpm_get_extalclk()));
123 lcd_putsf(0, line++, "RTCCLK:%3d.%02d KHz", TO_KHZ(__cpm_get_rtcclk()));
124} 213}
125 214
126static void display_enabled_clocks(void) 215static bool display_enabled_clocks(void)
127{ 216{
128 unsigned long lcr = REG_CPM_LCR; 217 unsigned long lcr = REG_CPM_LCR;
129 unsigned long clkgr0 = REG_CPM_CLKGR0; 218 unsigned long clkgr0 = REG_CPM_CLKGR0;
219 int x = 0;
220 int cur_item = -1;
221 bool is_last_item = false;
222
223 while(!is_done)
224 {
225 lcd_clear_display();
226
227 if (is_last_item || cur_item < 0)
228 cur_item = 0;
229 else if (cur_item >= 0)
230 cur_item += maxlines;
130 231
131 lcd_putsf(0, line++, "Low Power Mode : %s", 232 is_last_item = false;
132 ((lcr & LCR_LPM_MASK) == LCR_LPM_IDLE) ? 233
133 "IDLE" : (((lcr & LCR_LPM_MASK) == LCR_LPM_SLEEP) ? "SLEEP" : "HIBERNATE") 234 while(dbg_btn(&is_done, &x))
134 ); 235 {
135 236 lcd_clear_display();
136 lcd_putsf(0, line++, "Doze Mode : %s", 237 line = 0;
137 (lcr & LCR_DOZE) ? "ON" : "OFF"); 238 switch(cur_item)
138 if (lcr & LCR_DOZE) 239 {
139 lcd_putsf(0, line++, " duty : %d", (int)((lcr & LCR_DUTY_MASK) >> LCR_DUTY_LSB)); 240 case 0:
140 241 lcd_putsf(x, line++, "[%s]", "Enabled Clocks");
141 lcd_putsf(0, line++, "IPU : %s", 242 case 1:
142 (clkgr0 & CLKGR0_IPU) ? "stopped" : "running"); 243 lcd_putsf(x, line++, "Low Power Mode : %s",
143 lcd_putsf(0, line++, "DMAC : %s", 244 ((lcr & LCR_LPM_MASK) == LCR_LPM_IDLE) ?
144 (clkgr0 & CLKGR0_DMAC) ? "stopped" : "running"); 245 "IDLE" : (((lcr & LCR_LPM_MASK) == LCR_LPM_SLEEP) ? "SLEEP" : "HIBERNATE")
145 lcd_putsf(0, line++, "UHC : %s", 246 );
146 (clkgr0 & CLKGR0_UHC) ? "stopped" : "running"); 247 case 2:
147 lcd_putsf(0, line++, "LCD : %s", 248 lcd_putsf(x, line++, "Doze Mode : %s",
148 (clkgr0 & CLKGR0_LCD) ? "stopped" : "running"); 249 (lcr & LCR_DOZE) ? "ON" : "OFF");
149 lcd_putsf(0, line++, "CIM : %s", 250 case 3:
150 (clkgr0 & CLKGR0_CIM) ? "stopped" : "running"); 251 if (lcr & LCR_DOZE)
151 lcd_putsf(0, line++, "SADC : %s", 252 lcd_putsf(x, line++, " duty : %d",
152 (clkgr0 & CLKGR0_SADC) ? "stopped" : "running"); 253 (int)((lcr & LCR_DUTY_MASK) >> LCR_DUTY_LSB));
153 lcd_putsf(0, line++, "MSC0 : %s", 254 else if (cur_item == 2)
154 (clkgr0 & CLKGR0_MSC0) ? "stopped" : "running"); 255 cur_item++;
155 lcd_putsf(0, line++, "MSC1 : %s", 256 case 4:
156 (clkgr0 & CLKGR0_MSC1) ? "stopped" : "running"); 257 lcd_putsf(x, line++, "IPU : %s",
157 lcd_putsf(0, line++, "MSC2 : %s", 258 (clkgr0 & CLKGR0_IPU) ? STOPPED : RUNNING);
158 (clkgr0 & CLKGR0_MSC2) ? "stopped" : "running"); 259 case 5:
159 lcd_putsf(0, line++, "AIC : %s", 260 lcd_putsf(x, line++, "DMAC : %s",
160 (clkgr0 & CLKGR0_AIC) ? "stopped" : "running"); 261 (clkgr0 & CLKGR0_DMAC) ? STOPPED : RUNNING);
161 lcd_putsf(0, line++, "SSI1 : %s", 262 case 6:
162 (clkgr0 & CLKGR0_SSI1) ? "stopped" : "running"); 263 lcd_putsf(x, line++, "UHC : %s",
163 lcd_putsf(0, line++, "SSI2 : %s", 264 (clkgr0 & CLKGR0_UHC) ? STOPPED : RUNNING);
164 (clkgr0 & CLKGR0_SSI2) ? "stopped" : "running"); 265 case 7:
165 lcd_putsf(0, line++, "I2C0 : %s", 266 lcd_putsf(x, line++, "LCD : %s",
166 (clkgr0 & CLKGR0_I2C0) ? "stopped" : "running"); 267 (clkgr0 & CLKGR0_LCD) ? STOPPED : RUNNING);
167 lcd_putsf(0, line++, "I2C1 : %s", 268 case 8:
168 (clkgr0 & CLKGR0_I2C1) ? "stopped" : "running"); 269 lcd_putsf(x, line++, "CIM : %s",
169 lcd_putsf(0, line++, "UART1 : %s", 270 (clkgr0 & CLKGR0_CIM) ? STOPPED : RUNNING);
170 (clkgr0 & CLKGR0_UART1) ? "stopped" : "running"); 271 case 9:
171 lcd_putsf(0, line++, "UART0 : %s", 272 lcd_putsf(x, line++, "SADC : %s",
172 (clkgr0 & CLKGR0_UART0) ? "stopped" : "running"); 273 (clkgr0 & CLKGR0_SADC) ? STOPPED : RUNNING);
274 case 10:
275 lcd_putsf(x, line++, "MSC0 : %s",
276 (clkgr0 & CLKGR0_MSC0) ? STOPPED : RUNNING);
277 case 11:
278 lcd_putsf(x, line++, "MSC1 : %s",
279 (clkgr0 & CLKGR0_MSC1) ? STOPPED : RUNNING);
280 case 12:
281 lcd_putsf(x, line++, "MSC2 : %s",
282 (clkgr0 & CLKGR0_MSC2) ? STOPPED : RUNNING);
283 case 13:
284 lcd_putsf(x, line++, "AIC : %s",
285 (clkgr0 & CLKGR0_AIC) ? STOPPED : RUNNING);
286 case 14:
287 lcd_putsf(x, line++, "SSI1 : %s",
288 (clkgr0 & CLKGR0_SSI1) ? STOPPED : RUNNING);
289 case 15:
290 lcd_putsf(x, line++, "SSI2 : %s",
291 (clkgr0 & CLKGR0_SSI2) ? STOPPED : RUNNING);
292 case 16:
293 lcd_putsf(x, line++, "I2C0 : %s",
294 (clkgr0 & CLKGR0_I2C0) ? STOPPED : RUNNING);
295 case 17:
296 lcd_putsf(x, line++, "I2C1 : %s",
297 (clkgr0 & CLKGR0_I2C1) ? STOPPED : RUNNING);
298 case 18:
299 lcd_putsf(x, line++, "UART1 : %s",
300 (clkgr0 & CLKGR0_UART1) ? STOPPED : RUNNING);
301 case 19:
302 lcd_putsf(x, line++, "UART0 : %s",
303 (clkgr0 & CLKGR0_UART0) ? STOPPED : RUNNING);
304 default:
305 if (line <= maxlines + 1)
306 is_last_item = true;
307 }
308 lcd_update();
309 }
310 }
311 return true;
173} 312}
174 313
175bool dbg_ports(void) 314bool dbg_ports(void)
@@ -191,10 +330,10 @@ bool dbg_ports(void)
191 while(!done) 330 while(!done)
192 { 331 {
193 i = 0; 332 i = 0;
194 while(dbg_btn(&done, &x)) 333 while(dbg_btn_update(&done, &x))
195 { 334 {
196 i %= last_port; /*PORT: A B C D E F */ 335 i %= last_port; /*PORT: A B C D E F */
197 while(dbg_btn(&done, &x)) 336 while(dbg_btn_update(&done, &x))
198 { 337 {
199 line = 0; 338 line = 0;
200 lcd_puts(x, line++, "[GPIO Vals and Dirs]"); 339 lcd_puts(x, line++, "[GPIO Vals and Dirs]");
@@ -218,50 +357,11 @@ bool dbg_ports(void)
218 357
219 } 358 }
220 lcd_setfont(FONT_UI); 359 lcd_setfont(FONT_UI);
221#endif 360#endif /* CONFIG_CPU ==JZ4760B */
222 361
223 return false; 362 return false;
224} 363}
225 364
226extern uint32_t irqstackend,irqstackbegin;
227
228bool dbg_hw_info(void)
229{
230 int btn = 0;
231#ifdef HAVE_TOUCHSCREEN
232 int touch;
233#endif
234 struct tm *cur_time;
235
236 lcd_setfont(FONT_SYSFIXED);
237 while(btn ^ BUTTON_POWER)
238 {
239 lcd_clear_display();
240 line = 0;
241
242 uint32_t *ptr = &irqstackbegin;
243 for ( ; ptr < &irqstackend && *ptr == 0xDEADBEEF; ptr++) {}
244
245 lcd_putsf(0, line++, "IRQ stack max: %d", (uint32_t)&irqstackend - (uint32_t)ptr);
246
247 display_clocks();
248 display_enabled_clocks();
249#ifdef HAVE_TOUCHSCREEN
250 btn = button_read_device(&touch);
251 lcd_putsf(0, line++, "X: %d Y: %d BTN: 0x%X", touch>>16, touch&0xFFFF, btn);
252#else
253 btn = button_read_device();
254#endif
255 cur_time = get_time();
256 lcd_putsf(0, line++, "%02d/%02d/%04d %02d:%02d:%02d", cur_time->tm_mday,
257 cur_time->tm_mon, cur_time->tm_year, cur_time->tm_hour,
258 cur_time->tm_min, cur_time->tm_sec);
259 lcd_update();
260 sleep(HZ/16);
261 }
262 lcd_setfont(FONT_UI);
263 return true;
264}
265#endif 365#endif
266 366
267#ifdef BOOTLOADER 367#ifdef BOOTLOADER
@@ -370,3 +470,114 @@ void serial_dump_data(unsigned char* data, int len)
370 serial_putc( '\n' ); 470 serial_putc( '\n' );
371} 471}
372#endif 472#endif
473
474#ifndef BOOTLOADER
475static const struct {
476 unsigned char *desc; /* string or ID */
477 bool (*function) (void); /* return true if USB was connected */
478} hwinfo_items[] = {
479 { "", NULL }, /*RTC*/
480 { "", NULL }, /*CPUID*/
481 { "", NULL }, /*IRQSTACKMAX*/
482 { "Clocks", display_clocks},
483 { "Enabled Clocks", display_enabled_clocks},
484 { "", NULL}, /*TOUCH/BTN*/
485
486};
487
488static int hw_info_menu_action_cb(int btn, struct gui_synclist *lists)
489{
490 static long last_refresh = 0;
491 int selection = gui_synclist_get_sel_pos(lists);
492 if (btn == ACTION_STD_OK)
493 {
494 FOR_NB_SCREENS(i)
495 viewportmanager_theme_enable(i, false, NULL);
496 if (hwinfo_items[selection].function)
497 {
498 is_done = false;
499 hwinfo_items[selection].function();
500 }
501 btn = ACTION_REDRAW;
502 FOR_NB_SCREENS(i)
503 viewportmanager_theme_undo(i, false);
504 }
505 else if (btn == ACTION_STD_CONTEXT)
506 {
507 }
508 else if (btn == 0 && TIME_AFTER(current_tick, last_refresh + HZ / 2))
509 {
510 last_refresh = current_tick;
511 btn = ACTION_REDRAW;
512 /* to make menu items update */
513 }
514 return btn;
515}
516
517static const char* hw_info_menu_get_name(int item, void * data,
518 char *buffer, size_t buffer_len)
519{
520 (void)data;
521 struct tm *cur_time;
522 uint32_t *stackptr;
523 extern uint32_t irqstackend,irqstackbegin;
524 int btn;
525#ifdef HAVE_TOUCHSCREEN
526 int touch;
527#endif
528
529 switch(item)
530 {
531 /* create your dynamic items here */
532 case 0:/*RTC*/
533 cur_time = get_time();
534 snprintf(buffer, buffer_len, "%02d/%02d/%04d %02d:%02d:%02d",
535 cur_time->tm_mday,cur_time->tm_mon, cur_time->tm_year,
536 cur_time->tm_hour, cur_time->tm_min, cur_time->tm_sec);
537 return buffer;
538 case 1: /*cpuID*/
539 snprintf(buffer, buffer_len, "CPUID %X:%d",
540 read_cp0_15(), (REG_CPM_CLKGR0 & BIT31) >> 31);
541 return buffer;
542 case 2: /*IRQstack*/
543 stackptr = &irqstackbegin;
544 for ( ; stackptr < &irqstackend && *stackptr == 0xDEADBEEF; stackptr++) {}
545 snprintf(buffer, buffer_len, "IRQ stack max: %lu",
546 (uint32_t)&irqstackend - (uint32_t)stackptr);
547 return buffer;
548 case 5: /*Touch/BTN*/
549#ifdef HAVE_TOUCHSCREEN
550 btn = button_read_device(&touch);
551 snprintf(buffer, buffer_len, "X: %d Y: %d BTN: 0x%X",
552 touch>>16, touch&0xFFFF, btn);
553#else
554 btn = button_read_device();
555 snprintf(buffer, buffer_len, "BTN: 0x%X", btn);
556#endif
557 return buffer;
558 default: /* static items -- default */
559 return hwinfo_items[item].desc;
560 }
561 return "???";
562}
563
564static int hw_info_debug_menu(void)
565{
566 int h;
567 lcd_setfont(FONT_SYSFIXED);
568 lcd_getstringsize((unsigned char *)"A", NULL, &h);
569 maxlines = LCD_HEIGHT / h - 1;
570 is_done = false;
571 struct simplelist_info info;
572
573 simplelist_info_init(&info, "Hw Info", ARRAYLEN(hwinfo_items), NULL);
574 info.action_callback = hw_info_menu_action_cb;
575 info.get_name = hw_info_menu_get_name;
576 return (simplelist_show_list(&info)) ? 1 : 0;
577}
578
579bool dbg_hw_info(void)
580{
581 return hw_info_debug_menu() > 0;
582}
583#endif