貌似没有听说过你说的这种功能,之前有代码这样用过,你看看是否对你有点帮助。
enum{
HD_DISK='1',
ADDA,
TSP,
SD_MMC,
CAN,
KBD,
DM9000,
NANDFLASH,
CMOS,
TFT_LCD='A',
USB_OTG1362,
LED,
MOTOR,
PS2_KBD,
PS2_MOUSE,
PCMCIA,
ESC='Q'
};
void select(void)
{
int i;
int in_loop = 1;
char value = ESC;
char old_value = -1;
while(in_loop)
{
switch(value)
{
case HD_DISK:
Wait_Ready();
Data_Check(1);
old_value = ESC;
break;
case PS2_MOUSE:
if (init_flag == 0)
{
init_flag = 1;
InitMOUSE();
}
mdelay(100);
Ps_Mouse_Rec();
break;
case PS2_KBD:
if (init_flag == 0)
{
init_flag = 1;
Init_Platform4PS2_KBD();
}
mdelay(100);
Decode();
*pFIO_MASKA_S = 0x0020; //允许中断
break;
case DM9000:
if (init_flag == 0)
{
init_flag = 1;
eth_reset();
GetDM9000ID();
make_test_data();
}
eth_send(pack,1024);
break;
case KBD:
mdelay(1000);
scankb();
break;
case ADDA:
if (init_flag == 0)
{
init_flag = 1;
ADT7516_SPISS_SELECT();
ADT7516_SPI_init();
ADT7516_RST();
ADT7516_CTL();
ADT7516_TEST();
}
ADT7516_READ_REG(0x00,64,databuf);
Printf_VDD(2,databuf);
mdelay(10000);
mdelay(10000);
mdelay(10000);
ADT7516_DA(1,0x70);
ADT7516_DA(2,0x80);
ADT7516_DA(3,0x90);
ADT7516_DA(4,0xa0);
break;
case SD_MMC:
if (init_flag == 0)
{
init_flag = 1;
MMC_HardwareInitial();
MMC_Init();
}
check_test();
old_value = ESC;
break;
case NANDFLASH:
if (init_flag == 0)
{
init_flag = 1;
Init_NandFlash();
}
RW_Test();
old_value = ESC;
break;
case CAN:
if (init_flag == 0)
{
init_flag = 1;
MCP2515_init();
MCP2515_RST();
MCP2515_READ_REG(0x00,databuf,128);
MCP2515_Init();
MCP2515_RX0_Init();
MCP2515_TX0((void *)0);
*pFIO_MASKA_C = 0x0020;
}
MCP2515_Send_Enable(1);
MCP2515_Send_Disable(1);
break;
case CMOS:
if (init_flag == 0)
{
extern volatile uint16_t *pDestAddr;
init_flag = 1;
Init_Platform_cmos();
printf( "\nPlatform initialize success!\n\r" );
Init_Po3030();
printf( "\nPo3030 initialize success!\n\r" );
Video_Frame_Capture( (void*) pDestAddr );
}
if(cmosflag ==1)
{
old_value = TFT_LCD;
init_flag=0;
}
break;
case TFT_LCD:
if (init_flag == 0)
{
init_flag = 1;
if(cmosflag == 0){
gbrtorgb24();
}
TFT_DIS();
}
break;
case TSP:
if (init_flag == 0)
{
init_flag = 1;
Init_Platform_TSP();
ADS_SPI_Init();
ADS_INT_Enable();
}
break;
case MOTOR:
if (init_flag == 0)
{
#define STEP_MOTOR_CMD 1
#define DC_MOTOR_CMD 0
Eable_Motor();
init_flag = 1;
}
Step_motor(STEP_MOTOR_CMD);
DC_motor1(DC_MOTOR_CMD);
DC_motor2(DC_MOTOR_CMD);
break;
case LED:
if (init_flag == 0)
{
init_flag = 1;
Init_LED_CPLD();
}
for(i=0;i<10;i++)
{
leddisplay(3,i);
leddisplay(2,i);
leddisplay(1,i);
mdelay(10000);
}
break;
case USB_OTG1362:
if (init_flag == 0)
{
init_flag = 1;
usb();
}
if(usbflag==1)
{
old_value = ESC;
}
break;
case PCMCIA:
if (init_flag == 0)
{
Init_PCMCIAIO();
init_flag = 1;
}
Check_Pcmcia();
mdelay(1000);
mdelay(1000);
break;
case ESC:
CloseAll();
init_flag = 0;
UART_puts("select test\"HD_DISK\",please press 1!\r\n");
UART_puts("select test\"ADDA\",please press 2!\r\n");
UART_puts("select test\"TSP\",please press 3!\r\n");
UART_puts("select test\"SD_MMC\",please press 4!\r\n");
UART_puts("select test\"CAN\",please press 5!\r\n");
UART_puts("select test\"KBD\",please press 6!\r\n");
UART_puts("select test\"DM9000\",please press 7!\r\n");
UART_puts("select test\"NANDFLASH\",please press 8!\r\n");
UART_puts("select test\"CMOS\",please press 9!\r\n");
UART_puts("select test\"TFT_LCD\",please press A!\r\n");
UART_puts("select test\"USB_OTG1362\",please press B!\r\n");
UART_puts("select test\"LED\",please press C!\r\n");
UART_puts("select test\"MOTOR\",please press D!\r\n");
UART_puts("select test\"PS2_KBD\",please press E!\r\n");
UART_puts("select test\"PS2_MOUSE\",please press F!\r\n");
UART_puts("select test\"PCMCIA\",please press G!\r\n");
UART_puts("\"ESCAPE\",please press Q!\r\n");
break;
default:
break;
}
value = UART_getc();
if (value != -1){
UART_putc(value);
UART_puts("\r\n\r\n");
mdelay(1000);
old_value = value;
}
else{
if (old_value != ESC)
value = old_value;
}
}
}