summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/tcc780x/debug-tcc780x.c
blob: 14aa8c1c106ccd4c118e3e7dc92d7aa8c84857f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright (C) 2007 by Rob Purchase
 *
 * All files in this archive are subject to the GNU General Public License.
 * See the file COPYING in the source tree root for full license agreement.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/

#include "config.h"
#include "cpu.h"
#include "system.h"
#include "string.h"
#include <stdbool.h>
#include "button.h"
#include "lcd.h"
#include "sprintf.h"
#include "font.h"
#include "debug-target.h"
#include "adc.h"

/* IRQ status registers of debug interest only */
#define STS    (*(volatile unsigned long *)0xF3001008)
#define SRC    (*(volatile unsigned long *)0xF3001010)

bool __dbg_ports(void)
{
    return false;
}

bool __dbg_hw_info(void)
{
    int line = 0, i, button, oldline;
    bool done=false;
    char buf[100];

    lcd_setmargins(0, 0);
    lcd_setfont(FONT_SYSFIXED);
    lcd_clear_display();

    /* Put all the static text before the while loop */
    lcd_puts(0, line++, "[Hardware info]");

    line++;
    oldline=line;
    while(!done)
    {
        line = oldline;
        button = button_get(false);
        
        button &= ~BUTTON_REPEAT;
        
        if (button == BUTTON_POWER)
            done=true;

        snprintf(buf, sizeof(buf), "current tick: %08x Seconds running: %08d",
            (unsigned int)current_tick, (unsigned int)current_tick/100);  lcd_puts(0, line++, buf);
            
        snprintf(buf, sizeof(buf), "GPIOA: 0x%08x  GPIOB: 0x%08x",
            (unsigned int)GPIOA, (unsigned int)GPIOB);  lcd_puts(0, line++, buf);
        snprintf(buf, sizeof(buf), "GPIOC: 0x%08x  GPIOD: 0x%08x",
            (unsigned int)GPIOC, (unsigned int)GPIOD);  lcd_puts(0, line++, buf);
        snprintf(buf, sizeof(buf), "GPIOE: 0x%08x",
            (unsigned int)GPIOE);  lcd_puts(0, line++, buf);

        for (i = 0; i<4; i++)
        {
            snprintf(buf, sizeof(buf), "ADC%d: 0x%04x", i, adc_read(i));
                lcd_puts(0, line++, buf);
        }
        
        snprintf(buf, sizeof(buf), "STS: 0x%08x  SRC: 0x%08x",
            (unsigned int)STS, (unsigned int)SRC);  lcd_puts(0, line++, buf);
        
        lcd_update();
    }
    return false;
}