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

📄 show.c

📁 自动联想命令行处理代码
💻 C
字号:
#if !BASIC_BIOS

#include <stdio.h>
#include "44b0x.h"
#include "cli.h"
#include "uart.h"
#include "rtc.h"
#include "cpu.h"

static CommandNode CLI_NAME_SHOW =
{
    "show",                 // node command hint pointer
    "查询显示类",           // node command help pointer
    NULL,                   // node current input buffer pointer
    NULL,                   // down leaf pointer
    NULL,                   // right leaf pointer
    COMMAND_TYPE_KEY,       // node type
    NULL                    // node command value
};

static CommandNode CLI_NAME_DATE =
{
    "date",                 // node command hint pointer
    "系统日期",             // node command help pointer
    NULL,                   // node current input buffer pointer
    NULL,                   // down leaf pointer
    NULL,                   // right leaf pointer
    COMMAND_TYPE_KEY,       // node type
    CLI_SHOWDATE            // node command value
};

static CommandNode CLI_NAME_TIME =
{
    "time",                 // node command hint pointer
    "系统时间",             // node command help pointer
    NULL,                   // node current input buffer pointer
    NULL,                   // down leaf pointer
    NULL,                   // right leaf pointer
    COMMAND_TYPE_KEY,       // node type
    CLI_SHOWTIME            // node command value
};

static CommandNode CLI_NAME_VERSION =
{
    "version",              // node command hint pointer
    "版本类",               // node command help pointer
    NULL,                   // node current input buffer pointer
    NULL,                   // down leaf pointer
    NULL,                   // right leaf pointer
    COMMAND_TYPE_KEY,       // node type
    NULL                    // node command value
};

static CommandNode CLI_NAME_HARDWARE =
{
    "hardware",             // node command hint pointer
    "硬件版本",                 // node command help pointer
    NULL,                   // node current input buffer pointer
    NULL,                   // down leaf pointer
    NULL,                   // right leaf pointer
    COMMAND_TYPE_KEY,       // node type
    CLI_SHOWHARDWARE        // node command value
};

static CommandNode CLI_NAME_SOFTWARE =
{
    "software",             // node command hint pointer
    "软件版本",                 // node command help pointer
    NULL,                   // node current input buffer pointer
    NULL,                   // down leaf pointer
    NULL,                   // right leaf pointer
    COMMAND_TYPE_KEY,       // node type
    CLI_SHOWSOFTWARE        // node command value
};

static CommandNode CLI_NAME_BAUDRATE =
{
    "baudrate",             // node command hint pointer
    "波特率",               // node command help pointer
    NULL,                   // node current input buffer pointer
    NULL,                   // down leaf pointer
    NULL,                   // right leaf pointer
    COMMAND_TYPE_KEY,       // node type
    CLI_SHOWBAUDRATE        // node command value
};

static CommandNode CLI_NAME_IP =
{
    "ip-address",           // node command hint pointer
    "IP地址",               // node command help pointer
    NULL,                   // node current input buffer pointer
    NULL,                   // down leaf pointer
    NULL,                   // right leaf pointer
    COMMAND_TYPE_KEY,       // node type
    CLI_SHOWIP              // node command value
};

static CommandNode CLI_NAME_HELP = 
{
    "help",                 // node command hint pointer
    "显示帮助",             // node command help pointer
    NULL,                   // node current input buffer pointer
    NULL,                   // down leaf pointer
    NULL,                   // right leaf pointer
    COMMAND_TYPE_KEY,       // node type
    CLI_SHOWHELP            // node command value
};

CommandNode *CLI_ShowDate[] =
{
    &CLI_NAME_SHOW,     // show
    &CLI_NAME_DATE,     // date
    NULL
};

CommandNode *CLI_ShowTime[] =
{
    &CLI_NAME_SHOW,     // show
    &CLI_NAME_TIME,     // time
    NULL
};

CommandNode *CLI_ShowHardware[] =
{
    &CLI_NAME_SHOW,     // show
    &CLI_NAME_VERSION,  // version
    &CLI_NAME_HARDWARE, // hardware
    NULL
};

CommandNode *CLI_ShowSoftware[] =
{
    &CLI_NAME_SHOW,     // show
    &CLI_NAME_VERSION,  // version
    &CLI_NAME_SOFTWARE, // software
    NULL
};

CommandNode *CLI_ShowBaudrate[] =
{
    &CLI_NAME_SHOW,     // show
    &CLI_NAME_BAUDRATE, // baudrate
    NULL
};

CommandNode *CLI_ShowIp[] =
{
    &CLI_NAME_SHOW,     // show
    &CLI_NAME_IP,       // ip-address
    NULL
};

CommandNode *CLI_ShowHelp[] =
{
    &CLI_NAME_HELP,     // help
    NULL
};

void CLI_ShowProc( unsigned char key )
{
    switch( key )
    {
        case CLI_SHOWDATE:
            CLI_ShowDateProc();
            break;

        case CLI_SHOWTIME:
            CLI_ShowTimeProc();
            break;

        case CLI_SHOWHARDWARE:
            CLI_ShowVerHardProc();
            break;

        case CLI_SHOWSOFTWARE:
            CLI_ShowVerSoftProc();
            break;

        case CLI_SHOWBAUDRATE:
            CLI_ShowBaudRateProc();
            break;

        case CLI_SHOWIP:
            CLI_ShowIpProc();
            break;
            
		case CLI_SHOWHELP:
            CLI_ListHelp();
		    break;

        default:
            break;
    }

    return;
}

void CLI_ShowDateProc( void )
{
    struct reldate date;

    RTC_GetDate( &date );

    UART_Printf("\r\nCurrent date : %04d-%02d-%02d, %s",
        date.year, date.month, date.day, RTC_DayOfWeek[date.weekday] );

    return;
}

void CLI_ShowTimeProc( void )
{
    struct reltime time;

    RTC_GetTime( &time );

    UART_Printf("\r\nCurrent time : %02d:%02d:%02d",
        time.hour, time.minute, time.second );

    return;
}

void CLI_ShowVerHardProc( void )
{
    UART_Printf("\r\nHardware version:1.00");

    return;
}

void CLI_ShowVerSoftProc( void )
{
    UART_Printf("\r\nSoftware version:1.00");

    return;
}

void CLI_ShowBaudRateProc( void )
{
    UART_Printf("\r\nCOM1: %ld00 bps/s", (MCLK >>4 ) / rUBRDIV0 / 100 );

    return;
}

void CLI_ShowIpProc( void )
{
    UART_Printf("\r\n1.1.1.1");

    return;
}

#endif

⌨️ 快捷键说明

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