⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debug_menu.c

📁 编译后直接运行的MP3播放器全部C语言源代码 一个包含FAT文件系统、系统引导 Boot、FLASH Driver等内容的
💻 C
📖 第 1 页 / 共 3 页
字号:
        case 3:            lcd_puts(0, 0, "PIOData    ");            snprintf(buf, 32, "ed: %05x  ", mas_readreg(0xed) & 0xfffff);            break;        case 4:            lcd_puts(0, 0, "Startup Cfg");            snprintf(buf, 32, "e6: %05x  ", mas_readreg(0xe6) & 0xfffff);            break;        case 5:            lcd_puts(0, 0, "KPrescale  ");            snprintf(buf, 32, "e7: %05x  ", mas_readreg(0xe7) & 0xfffff);            break;        case 6:            lcd_puts(0, 0, "KBass      ");            snprintf(buf, 32, "6b: %05x   ", mas_readreg(0x6b) & 0xfffff);            break;        case 7:            lcd_puts(0, 0, "KTreble    ");            snprintf(buf, 32, "6f: %05x   ", mas_readreg(0x6f) & 0xfffff);            break;        case 8:            mas_readmem(MAS_BANK_D0, 0x300, &val, 1);            lcd_puts(0, 0, "Frame Count");            snprintf(buf, 32, "0/300: %04x", val & 0xffff);            break;        case 9:            mas_readmem(MAS_BANK_D0, 0x301, &val, 1);            lcd_puts(0, 0, "Status1    ");            snprintf(buf, 32, "0/301: %04x", val & 0xffff);            break;        case 10:            mas_readmem(MAS_BANK_D0, 0x302, &val, 1);            lcd_puts(0, 0, "Status2    ");            snprintf(buf, 32, "0/302: %04x", val & 0xffff);            break;        case 11:            mas_readmem(MAS_BANK_D0, 0x303, &val, 1);            lcd_puts(0, 0, "CRC Count  ");            snprintf(buf, 32, "0/303: %04x", val & 0xffff);            break;        case 12:            mas_readmem(MAS_BANK_D0, 0x36d, &val, 1);            lcd_puts(0, 0, "PLLOffset48");            snprintf(buf, 32, "0/36d %05x", val & 0xfffff);            break;        case 13:            mas_readmem(MAS_BANK_D0, 0x32d, &val, 1);            lcd_puts(0, 0, "PLLOffset48");            snprintf(buf, 32, "0/32d %05x", val & 0xfffff);            break;        case 14:            mas_readmem(MAS_BANK_D0, 0x36e, &val, 1);            lcd_puts(0, 0, "PLLOffset44");            snprintf(buf, 32, "0/36e %05x", val & 0xfffff);            break;        case 15:            mas_readmem(MAS_BANK_D0, 0x32e, &val, 1);            lcd_puts(0, 0, "PLLOffset44");            snprintf(buf, 32, "0/32e %05x", val & 0xfffff);            break;        case 16:            mas_readmem(MAS_BANK_D0, 0x36f, &val, 1);            lcd_puts(0, 0, "OutputConf ");            snprintf(buf, 32, "0/36f %05x", val & 0xfffff);            break;        case 17:            mas_readmem(MAS_BANK_D0, 0x32f, &val, 1);            lcd_puts(0, 0, "OutputConf ");            snprintf(buf, 32, "0/32f %05x", val & 0xfffff);            break;        case 18:            mas_readmem(MAS_BANK_D1, 0x7f8, &val, 1);            lcd_puts(0, 0, "LL Gain    ");            snprintf(buf, 32, "1/7f8 %05x", val & 0xfffff);            break;        case 19:            mas_readmem(MAS_BANK_D1, 0x7f9, &val, 1);            lcd_puts(0, 0, "LR Gain    ");            snprintf(buf, 32, "1/7f9 %05x", val & 0xfffff);            break;        case 20:            mas_readmem(MAS_BANK_D1, 0x7fa, &val, 1);            lcd_puts(0, 0, "RL Gain    ");            snprintf(buf, 32, "1/7fa %05x", val & 0xfffff);            break;        case 21:            mas_readmem(MAS_BANK_D1, 0x7fb, &val, 1);            lcd_puts(0, 0, "RR Gain    ");            snprintf(buf, 32, "1/7fb %05x", val & 0xfffff);            break;        case 22:            lcd_puts(0, 0, "L Trailbits");            snprintf(buf, 32, "c5: %05x   ", mas_readreg(0xc5) & 0xfffff);            break;        case 23:            lcd_puts(0, 0, "R Trailbits");            snprintf(buf, 32, "c6: %05x   ", mas_readreg(0xc6) & 0xfffff);            break;        }        lcd_puts(0, 1, buf);                button = button_get_w_tmo(HZ/5);        switch(button)        {        case BUTTON_STOP:            return false;        case BUTTON_LEFT:            currval--;            if(currval < 0)                currval = 23;            break;        case BUTTON_RIGHT:            currval++;            if(currval > 23)                currval = 0;            break;        case BUTTON_PLAY:            pll_toggle = !pll_toggle;            if(pll_toggle)            {                /* 14.31818 MHz crystal */                pll48 = 0x5d9d0;                pll44 = 0xfffceceb;                config = 0;            }            else            {                /* 14.725 MHz crystal */                pll48 = 0x2d0de;                pll44 = 0xfffa2319;                config = 0;            }            mas_writemem(MAS_BANK_D0, 0x32d, &pll48, 1);            mas_writemem(MAS_BANK_D0, 0x32e, &pll44, 1);            mas_writemem(MAS_BANK_D0, 0x32f, &config, 1);            mas_run(0x475);            break;        }    }    return false;}#endifstatic bool view_runtime(void){    char s[32];    bool done = false;    int state = 1;    while(!done)    {        int y=0;        int t;        int key;        lcd_clear_display();#ifdef HAVE_LCD_BITMAP        lcd_puts(0, y++, "Running time:");        y++;#endif        if (state & 1) {            if (charger_inserted())            {                global_settings.runtime = 0;            }            else            {                global_settings.runtime += ((current_tick - lasttime) / HZ);            }            lasttime = current_tick;            t = global_settings.runtime;            lcd_puts(0, y++, "Current time");        }        else {            t = global_settings.topruntime;            lcd_puts(0, y++, "Top time");        }            snprintf(s, sizeof(s), "%dh %dm %ds",                 t / 3600, (t % 3600) / 60, t % 60);        lcd_puts(0, y++, s);        lcd_update();        /* Wait for a key to be pushed */        key = button_get_w_tmo(HZ);        switch(key) {#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD)            case BUTTON_STOP | BUTTON_REL:#elif HAVE_RECORDER_KEYPAD            case BUTTON_OFF | BUTTON_REL:#endif                done = true;                break;            case BUTTON_LEFT:            case BUTTON_RIGHT:                if (state == 1)                    state = 2;                else                    state = 1;                break;                            case BUTTON_PLAY:                lcd_clear_display();                lcd_puts(0,0,"Clear time?");                lcd_puts(0,1,"PLAY = Yes");                lcd_update();                while (1) {                    key = button_get_w_tmo(HZ*10);                    if ( key & BUTTON_REL )                        continue;                    if ( key == BUTTON_PLAY ) {                        if ( state == 1 )                            global_settings.runtime = 0;                        else                            global_settings.topruntime = 0;                    }                    break;                }                break;        }    }    return false;}static bool dbg_disk_info(void){    char buf[128];    bool done = false;    int i;    int page = 0;    const int max_page = 10;    unsigned short* identify_info = ata_get_identify();    bool timing_info_present = false;    char pio3[2], pio4[2];#ifdef HAVE_LCD_BITMAP    lcd_setmargins(0, 0);#endif        while(!done)    {        int y=0;        int key;        lcd_clear_display();#ifdef HAVE_LCD_BITMAP        lcd_puts(0, y++, "Disk info:");        y++;#endif        switch (page) {            case 0:                for (i=0; i < 20; i++)                    ((unsigned short*)buf)[i]=identify_info[i+27];                buf[40]=0;                /* kill trailing space */                for (i=39; i && buf[i]==' '; i--)                    buf[i] = 0;                lcd_puts(0, y++, "Model");                lcd_puts_scroll(0, y++, buf);                break;            case 1:                for (i=0; i < 4; i++)                    ((unsigned short*)buf)[i]=identify_info[i+23];                buf[8]=0;                lcd_puts(0, y++, "Firmware");                lcd_puts(0, y++, buf);                break;            case 2:                snprintf(buf, sizeof buf, "%d MB",                         ((unsigned)identify_info[61] << 16 |                           (unsigned)identify_info[60]) / 2048 );                lcd_puts(0, y++, "Size");                lcd_puts(0, y++, buf);                break;            case 3: {                unsigned int free;                fat_size( NULL, &free );                snprintf(buf, sizeof buf, "%d MB",  free / 1024 );                lcd_puts(0, y++, "Free");                lcd_puts(0, y++, buf);                break;            }            case 4:                snprintf(buf, sizeof buf, "%d ms", ata_spinup_time * (1000/HZ));                lcd_puts(0, y++, "Spinup time");                lcd_puts(0, y++, buf);                break;            case 5:                i = identify_info[83] & (1<<3);                lcd_puts(0, y++, "Power mgmt:");                lcd_puts(0, y++, i ? "enabled" : "unsupported");                break;            case 6:                i = identify_info[83] & (1<<9);                lcd_puts(0, y++, "Noise mgmt:");                lcd_puts(0, y++, i ? "enabled" : "unsupported");                break;            case 7:                i = identify_info[82] & (1<<6);                lcd_puts(0, y++, "Read-ahead:");                lcd_puts(0, y++, i ? "enabled" : "unsupported");                break;            case 8:                timing_info_present = identify_info[53] & (1<<1);                if(timing_info_present) {                    pio3[1] = 0;                    pio4[1] = 0;                    lcd_puts(0, y++, "PIO modes:");                    pio3[0] = (identify_info[64] & (1<<0)) ? '3' : 0;                    pio4[0] = (identify_info[64] & (1<<1)) ? '4' : 0;                    snprintf(buf, 128, "0 1 2 %s %s", pio3, pio4);                    lcd_puts(0, y++, buf);                } else {                    lcd_puts(0, y++, "No PIO mode info");                }                break;            case 9:                timing_info_present = identify_info[53] & (1<<1);                if(timing_info_present) {                    lcd_puts(0, y++, "Cycle times");                    snprintf(buf, 128, "%dns/%dns",                             identify_info[67],                             identify_info[68]);                    lcd_puts(0, y++, buf);                } else {                    lcd_puts(0, y++, "No timing info");                }                break;            case 10:                timing_info_present = identify_info[53] & (1<<1);                if(timing_info_present) {                    i = identify_info[49] & (1<<11);                    snprintf(buf, 128, "IORDY support: %s", i ? "yes" : "no");                    lcd_puts(0, y++, buf);                    i = identify_info[49] & (1<<10);                    snprintf(buf, 128, "IORDY disable: %s", i ? "yes" : "no");                    lcd_puts(0, y++, buf);                } else {                    lcd_puts(0, y++, "No timing info");                }                break;        }        lcd_update();        /* Wait for a key to be pushed */        key = button_get_w_tmo(HZ*5);        switch(key) {#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD)            case BUTTON_STOP | BUTTON_REL:#else            case BUTTON_OFF | BUTTON_REL:#endif                done = true;                break;            case BUTTON_LEFT:                if (--page < 0)                    page = max_page;                break;                            case BUTTON_RIGHT:                if (++page > max_page)                    page = 0;                break;            case BUTTON_PLAY:                if (page == 3) {                    mpeg_stop(); /* stop playback, to avoid disk access */                    lcd_clear_display();                    lcd_puts(0,0,"Scanning");                    lcd_puts(0,1,"disk...");                    lcd_update();                    fat_recalc_free();                }                break;        }        lcd_stop_scroll();    }    return false;}bool dbg_save_roms(void){    int fd;    fd = creat("/internal_rom_0000-FFFF.bin", O_WRONLY);    if(fd >= 0)    {        write(fd, (void *)0, 0x10000);        close(fd);    }        fd = creat("/internal_rom_2000000-203FFFF.bin", O_WRONLY);    if(fd >= 0)    {        write(fd, (void *)0x2000000, 0x40000);        close(fd);    }    return false;}#ifdef HAVE_FMRADIOextern int debug_fm_detection;bool dbg_fm_radio(void){    char buf[32];    int button;    bool fm_detected;#ifdef HAVE_LCD_BITMAP    lcd_setmargins(0, 0);#endif    while(1)    {        lcd_clear_display();        fm_detected = radio_hardware_present();                snprintf(buf, sizeof buf, "HW detected: %s", fm_detected?"yes":"no");        lcd_puts(0, 0, buf);        snprintf(buf, sizeof buf, "Result: %08x", debug_fm_detection);        lcd_puts(0, 1, buf);        lcd_update();                button = button_get(true);        switch(button)        {#ifdef HAVE_RECORDER_KEYPAD            case BUTTON_OFF:#else            case BUTTON_STOP:#endif                return false;        }    }    return false;}#endifbool debug_menu(void){    int m;    bool result;    struct menu_items items[] = {        { "Dump ROM contents", dbg_save_roms },        { "View I/O ports", dbg_ports },#ifdef HAVE_LCD_BITMAP#ifdef HAVE_RTC        { "View/clr RTC RAM", dbg_rtc },#endif /* HAVE_RTC */#endif /* HAVE_LCD_BITMAP */        { "View OS stacks", dbg_os },#ifdef HAVE_MAS3507D        { "View MAS info", dbg_mas_info },#endif        { "View MAS regs", dbg_mas },#ifdef HAVE_MAS3587F        { "View MAS codec", dbg_mas_codec },#endif#ifdef HAVE_LCD_BITMAP        { "View battery", view_battery },#endif        { "View HW info", dbg_hw_info },        { "View partitions", dbg_partitions },        { "View disk info", dbg_disk_info },#ifdef HAVE_LCD_BITMAP        { "View mpeg thread", dbg_mpeg_thread },#ifdef PM_DEBUG        { "pm histogram", peak_meter_histogram},#endif /* PM_DEBUG */#endif /* HAVE_LCD_BITMAP */        { "View runtime", view_runtime },#ifdef HAVE_FMRADIO        { "FM Radio", dbg_fm_radio },#endif    };    m=menu_init( items, sizeof items / sizeof(struct menu_items) );    result = menu_run(m);    menu_exit(m);        return result;}#endif /* SIMULATOR */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -