diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/debug.c | 210 |
1 files changed, 157 insertions, 53 deletions
diff --git a/firmware/debug.c b/firmware/debug.c index c64054b115..36c38e9ff0 100644 --- a/firmware/debug.c +++ b/firmware/debug.c | |||
@@ -28,13 +28,11 @@ static char debugbuf[200]; | |||
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #ifndef SIMULATOR /* allow non archos platforms to display output */ | 30 | #ifndef SIMULATOR /* allow non archos platforms to display output */ |
31 | #ifdef ARCHOS_RECORDER | ||
32 | #include "kernel.h" | 31 | #include "kernel.h" |
33 | #include "button.h" | 32 | #include "button.h" |
34 | #include "system.h" | 33 | #include "system.h" |
35 | #include "lcd.h" | 34 | #include "lcd.h" |
36 | #include "adc.h" | 35 | #include "adc.h" |
37 | #endif | ||
38 | 36 | ||
39 | void debug_init(void) | 37 | void debug_init(void) |
40 | { | 38 | { |
@@ -217,10 +215,10 @@ void debugf(char *fmt, ...) | |||
217 | /*---------------------------------------------------*/ | 215 | /*---------------------------------------------------*/ |
218 | /* SPECIAL DEBUG STUFF */ | 216 | /* SPECIAL DEBUG STUFF */ |
219 | /*---------------------------------------------------*/ | 217 | /*---------------------------------------------------*/ |
220 | #ifdef ARCHOS_RECORDER | ||
221 | extern int ata_device; | 218 | extern int ata_device; |
222 | extern int ata_io_address; | 219 | extern int ata_io_address; |
223 | 220 | ||
221 | #ifdef ARCHOS_RECORDER | ||
224 | /* Test code!!! */ | 222 | /* Test code!!! */ |
225 | void dbg_ports(void) | 223 | void dbg_ports(void) |
226 | { | 224 | { |
@@ -236,59 +234,165 @@ void dbg_ports(void) | |||
236 | 234 | ||
237 | while(1) | 235 | while(1) |
238 | { | 236 | { |
239 | porta = PADR; | 237 | porta = PADR; |
240 | portb = PBDR; | 238 | portb = PBDR; |
241 | portc = PCDR; | 239 | portc = PCDR; |
242 | 240 | ||
243 | snprintf(buf, 32, "PADR: %04x", porta); | 241 | snprintf(buf, 32, "PADR: %04x", porta); |
244 | lcd_puts(0, 0, buf); | 242 | lcd_puts(0, 0, buf); |
245 | snprintf(buf, 32, "PBDR: %04x", portb); | 243 | snprintf(buf, 32, "PBDR: %04x", portb); |
246 | lcd_puts(0, 1, buf); | 244 | lcd_puts(0, 1, buf); |
247 | 245 | ||
248 | snprintf(buf, 32, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4)); | 246 | snprintf(buf, 32, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4)); |
249 | lcd_puts(0, 2, buf); | 247 | lcd_puts(0, 2, buf); |
250 | snprintf(buf, 32, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5)); | 248 | snprintf(buf, 32, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5)); |
251 | lcd_puts(0, 3, buf); | 249 | lcd_puts(0, 3, buf); |
252 | snprintf(buf, 32, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6)); | 250 | snprintf(buf, 32, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6)); |
253 | lcd_puts(0, 4, buf); | 251 | lcd_puts(0, 4, buf); |
254 | snprintf(buf, 32, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7)); | 252 | snprintf(buf, 32, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7)); |
255 | lcd_puts(0, 5, buf); | 253 | lcd_puts(0, 5, buf); |
256 | 254 | ||
257 | battery_voltage = (adc_read(6) * 6465) / 10000; | 255 | battery_voltage = (adc_read(6) * BATTERY_SCALE_FACTOR) / 10000; |
258 | batt_int = battery_voltage / 100; | 256 | batt_int = battery_voltage / 100; |
259 | batt_frac = battery_voltage % 100; | 257 | batt_frac = battery_voltage % 100; |
260 | 258 | ||
261 | snprintf(buf, 32, "Battery: %d.%02dV", batt_int, batt_frac); | 259 | snprintf(buf, 32, "Battery: %d.%02dV", batt_int, batt_frac); |
262 | lcd_puts(0, 6, buf); | 260 | lcd_puts(0, 6, buf); |
263 | 261 | ||
264 | snprintf(buf, 32, "ATA: %s, 0x%x", | 262 | snprintf(buf, 32, "ATA: %s, 0x%x", |
265 | ata_device?"slave":"master", ata_io_address); | 263 | ata_device?"slave":"master", ata_io_address); |
266 | lcd_puts(0, 7, buf); | 264 | lcd_puts(0, 7, buf); |
267 | 265 | ||
268 | lcd_update(); | 266 | lcd_update(); |
269 | sleep(HZ/10); | 267 | sleep(HZ/10); |
270 | 268 | ||
271 | button = button_get(false); | 269 | button = button_get(false); |
272 | 270 | ||
273 | switch(button) | 271 | switch(button) |
274 | { | 272 | { |
275 | case BUTTON_ON: | 273 | case BUTTON_ON: |
276 | /* Toggle the charger */ | 274 | /* Toggle the charger */ |
277 | PBDR ^= 0x20; | 275 | PBDR ^= 0x20; |
278 | break; | 276 | break; |
279 | 277 | ||
280 | case BUTTON_UP: | 278 | case BUTTON_UP: |
281 | /* Toggle the IDE power */ | 279 | /* Toggle the IDE power */ |
282 | PADR ^= 0x20; | 280 | PADR ^= 0x20; |
283 | break; | 281 | break; |
284 | 282 | ||
285 | case BUTTON_OFF: | 283 | case BUTTON_OFF: |
286 | /* Disable the charger */ | 284 | /* Disable the charger */ |
287 | PBDR |= 0x20; | 285 | PBDR |= 0x20; |
288 | /* Enable the IDE power */ | 286 | /* Enable the IDE power */ |
289 | PADR |= 0x20; | 287 | PADR |= 0x20; |
290 | return; | 288 | return; |
291 | } | 289 | } |
290 | } | ||
291 | } | ||
292 | #else | ||
293 | void dbg_ports(void) | ||
294 | { | ||
295 | unsigned short porta; | ||
296 | unsigned short portb; | ||
297 | unsigned char portc; | ||
298 | char buf[32]; | ||
299 | int button; | ||
300 | int battery_voltage; | ||
301 | int batt_int, batt_frac; | ||
302 | int currval = 0; | ||
303 | |||
304 | lcd_clear_display(); | ||
305 | |||
306 | while(1) | ||
307 | { | ||
308 | porta = PADR; | ||
309 | portb = PBDR; | ||
310 | portc = PCDR; | ||
311 | |||
312 | switch(currval) | ||
313 | { | ||
314 | case 0: | ||
315 | snprintf(buf, 32, "PADR: %04x ", porta); | ||
316 | break; | ||
317 | case 1: | ||
318 | snprintf(buf, 32, "PBDR: %04x ", portb); | ||
319 | break; | ||
320 | case 2: | ||
321 | snprintf(buf, 32, "AN0: %03x ", adc_read(0)); | ||
322 | break; | ||
323 | case 3: | ||
324 | snprintf(buf, 32, "AN1: %03x ", adc_read(1)); | ||
325 | break; | ||
326 | case 4: | ||
327 | snprintf(buf, 32, "AN2: %03x ", adc_read(2)); | ||
328 | break; | ||
329 | case 5: | ||
330 | snprintf(buf, 32, "AN3: %03x ", adc_read(3)); | ||
331 | break; | ||
332 | case 6: | ||
333 | snprintf(buf, 32, "AN4: %03x ", adc_read(4)); | ||
334 | break; | ||
335 | case 7: | ||
336 | snprintf(buf, 32, "AN5: %03x ", adc_read(5)); | ||
337 | break; | ||
338 | case 8: | ||
339 | snprintf(buf, 32, "AN6: %03x ", adc_read(6)); | ||
340 | break; | ||
341 | case 9: | ||
342 | snprintf(buf, 32, "AN7: %03x ", adc_read(7)); | ||
343 | break; | ||
344 | case 10: | ||
345 | snprintf(buf, 32, "%s, 0x%x ", | ||
346 | ata_device?"slv":"mst", ata_io_address); | ||
347 | break; | ||
348 | } | ||
349 | lcd_puts(0, 0, buf); | ||
350 | |||
351 | battery_voltage = (adc_read(6) * BATTERY_SCALE_FACTOR) / 10000; | ||
352 | batt_int = battery_voltage / 100; | ||
353 | batt_frac = battery_voltage % 100; | ||
354 | |||
355 | snprintf(buf, 32, "Batt: %d.%02dV", batt_int, batt_frac); | ||
356 | lcd_puts(0, 1, buf); | ||
357 | |||
358 | sleep(HZ/5); | ||
359 | |||
360 | button = button_get(false); | ||
361 | |||
362 | switch(button) | ||
363 | { | ||
364 | #ifndef ARCHOS_PLAYER_OLD | ||
365 | case BUTTON_ON: | ||
366 | /* Toggle the charger */ | ||
367 | PBDR ^= 0x20; | ||
368 | break; | ||
369 | |||
370 | case BUTTON_PLAY: | ||
371 | /* Toggle the IDE power */ | ||
372 | PADR ^= 0x20; | ||
373 | break; | ||
374 | #endif | ||
375 | case BUTTON_STOP: | ||
376 | #ifndef ARCHOS_PLAYER_OLD | ||
377 | /* Disable the charger */ | ||
378 | PBDR |= 0x20; | ||
379 | /* Enable the IDE power */ | ||
380 | PADR |= 0x20; | ||
381 | #endif | ||
382 | return; | ||
383 | |||
384 | case BUTTON_LEFT: | ||
385 | currval--; | ||
386 | if(currval < 0) | ||
387 | currval = 10; | ||
388 | break; | ||
389 | |||
390 | case BUTTON_RIGHT: | ||
391 | currval++; | ||
392 | if(currval > 10) | ||
393 | currval = 0; | ||
394 | break; | ||
395 | } | ||
292 | } | 396 | } |
293 | } | 397 | } |
294 | #endif | 398 | #endif |