#include "myprintf.h"
#include "clock.h"
#include "uart.h"
#include "nand.h"
#include "rtc.h"
#include "ac97.h"
// 执行内存中的bin文件
int go(int argc, char * argv[])
{
int addr = 0x21000000;
void (*fp)(void);
if (argc >= 2)
addr = atoi(argv[1]);
my_printf("go to address 0x%x\r\n", addr);
fp = (void (*)(void))addr;
fp();
return 0;
}
int loadx(int argc, char *argv[])
{
char * p = (char *)0x21000000;
if (argc >= 2)
p = (char *)atoi(argv[1]);
my_printf("load bin file by xmodem to address 0x%x\n", (int)p);
xmodem_recv(p);
my_printf("loadx finished! \n");
return 0;
}
int help(int argc,char * argv[])
{
my_printf("do_command<%s>\n",argv[0]);
my_printf("help massage :\n");
my_printf("md - memmory display \n");
my_printf("mw - memory write \n");
my_printf("nandr - addr size \n");
my_printf("nandw - addr data size \n");
}
int md (int argc,char *argv[])
{
unsigned long *p=(unsigned long *)0;
int i,j;
my_printf("do_commend<%s>\n","md address");
if(argc<=1)
{
my_printf("Usage :\n %s\n","md address");
return 1;
}
if(argc>=2)
p=(unsigned long *)atoi(argv[1]);
for (j = 0; j < 16; j++)
{
my_printf("%x: ", p);
for (i = 0; i < 4; i++)
my_printf("%x ", *p++);
my_printf("\n");
}
return 0;
}
int mw(int argc,char *argv[])
{
unsigned long *p=(unsigned long *)0;
int v=0;
my_printf("do_command<%s>\n",argv[0]);
if(argc<=2)
{
my_printf("Usage :\n%s\n","md adddress data");
return 1;
}
if(argc>2)
p=(unsigned long *)atoi(argv[1]);
if(argc>=3)
v=atoi(argv[2]);
*p=v;
return ;
}
void run_command(int argc,char *argv[])
{ unsigned char buf[2048];
if(strcmp(argv[0],"help")==0)
{
help(argc,argv);
return;
}
if((strcmp(argv[0],"q")==0)||(strcmp(argv[0],"Q")==0))
{
ac97_int_disable();
ac97_write_cmd(0x26, (1<<12));
return ;
}
if(strcmp(argv[0],"md")==0)
{
md(argc,argv);
return ;
}
if(strcmp(argv[0],"mw")==0)
{
mw(argc,argv);
return ;
}
if (strcmp(argv[0], "loadb") == 0)
{
loadb(argc, argv);
return ;
}
if (strcmp(argv[0], "go") == 0)
{
go(argc, argv);
return;
}
if(strcmp(argv[0],"settime")==0)
{
rtc_set_time();
return ;
}
if(strcmp(argv[0],"time")==0)
{
rtc_show_time();
return ;
}
if (strcmp(argv[0], "loadx") == 0)
loadx(argc, argv);
if(argc>=1)
my_printf("unknown command '%s'-try 'help'\n",argv[0]);
return;
}
cmomand.c
最新推荐文章于 2023-06-18 13:16:28 发布