test_fs.c

来自「Atmega64单片机程序(完整工程)」· C语言 代码 · 共 140 行

C
140
字号
/*--------------File Info-------------------------------------------------------
** 文   件   名:    TEST_FS.c
** 最后修改日期:    2008.04.04
** 版        本:    V1.0
** 描        述:    FS测试函数				
**------------------------------------------------------------------------------
** Created   by:    		
** Created date:			
*******************************************************************************/
#include "SYS_Config.h"
#include "FS_Config.h"
#include "USART1.h"
#include "TEST_FS.h"

/********************************************/
//   描述:连接PC机串口,观察超级终端输出                    
/********************************************/
#if FS_TEST_EN

#include "fat.h"

//测试逻辑盘驱动信息
void Test_FS_Information(void)
{
    AddFileDriver( SD_Command );//加载SD卡驱动程序 
}

void * FS_Function_Test[][2]=
{
    (void *)Test_FS_Information, " FS_Information   ",
    (void *)Test_FS_Information, " FS_Information   ",
    (void *)Test_FS_Information, " FS_Information   ",
    (void *)Test_FS_Information, " FS_Information   ",
    
    (void *)Test_FS_Information, " FS_Information   ",
    (void *)Test_FS_Information, " FS_Information   ",
    (void *)Test_FS_Information, " FS_Information   ",
    (void *)Test_FS_Information, " FS_Information   ",
    
    (void *)Test_FS_Information, " FS_Information   ",
    (void *)Test_FS_Information, " FS_Information   ",
    (void *)Test_FS_Information, " FS_Information   ",
    (void *)Test_FS_Information, " FS_Information   ",
    
    (void *)Test_FS_Information, " FS_Information   ",
    (void *)Test_FS_Information, " FS_Information   ",
    (void *)Test_FS_Information, " FS_Information   ",
    (void *)Test_FS_Information, " FS_Information   ",
    0x00,0x00
};

//超级终端测试程序,波特率19200,8M OSC
void FS_TEST(void)
{
     INT8U temp,temp1,num;
   
     while(1)
     {
	temp=0;
                                       
	Uart1_SendString("\n\n**************************************************************************************");
	Uart1_SendString("\n*                       Welcome to use File System test program  V1.0                   *");
	Uart1_SendString("\n*                                  Version 1.0                                       *");    
	Uart1_SendString("\n*                                Email:jiangjx@ake.com.cn                            *");
	Uart1_SendString("\n*                          UART Config--COM:19200bps,8Bit,NP                         *\n\n\n");
	
	while(1)
	{   //display menu
	    if(temp<10)
	    {
	        putchar1(' ');
	        putchar1(temp+'0');
	    }  
	    else
	    { 
	        putchar1(temp/10+'0');
	        putchar1(temp%10+'0');
	    }
	    putchar1(':');
	    Uart1_SendString(FS_Function_Test[temp][1]);
	   
	    temp++;
	    
	    if( (int)(FS_Function_Test[temp][0])==0 )
	    {
		putchar1('\n');
		break;
	    }
	    if( (temp%4)==0 )
		putchar1('\n');
	}
	
	Uart1_SendString("\n**************************Please Select the function to test? >> ");
	
	temp=0;
	temp1=0;
	num=0;
	while(temp1!=0x0D)//如果不是回车键
	{
	    temp1=getchar1();
	    if(temp1==0x1B)//如果是ESC键。退出SD卡测试菜单
	    {
	        Uart1_SendString("\nExit File System test program\n");
		return;
	    }    
		
	    if(temp1>='0'&&temp1<='9')
	    {
	        putchar1(temp1); 
		num++;
		switch(num)
		{
		    case 1:temp=temp1-'0';break;
		    case 2:
		          {
			      temp=temp*10+temp1-'0';
		              num=0;
			      putchar1(' ');
			      break;
			  }     
		    default:num=0;break;
		} 
	    }
	}
	
	putchar1('\n');
	if( temp>=0 && (temp<(sizeof(FS_Function_Test)/4-1)) ) 
	{
	    Uart1_SendString("The Result:\n");
	    ( (void (*)(void))(FS_Function_Test[temp][0]) )();
	}  
	else Uart1_SendString("CMD Error!");
     }
}


#endif;


⌨️ 快捷键说明

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