#include "minios7.h"
#include "MFS.h"
#include <stdlib.h>
#include <stdio.h>
#include <alloc.h>

void main()
{
	int b;
	int iRet=-1;
	InitLib();
	LCD_Init();
	*LCD_BackLight=20;
	LCD_Gotoxy(0,0);	
	InstallCom(1, 115200L,8, 0, 1); 
	printCom1 (" Mem1net128= %lu byte \n",(unsigned long)coreleft());
	
	iRet=test_MFS();
	
	//printCom1(" main.c iRet= %d ",iRet);
	if (iRet!=0)
	{
		LCD_PutsAt(0,1,"MFS test fail",0);
		while(1)
		{
			if(ReadCom1()=='q')
			{
				return;
			}
		}
	}
	LCD_PutsAt(0,1,"MFS test OK",0);
	Delay(5000);
	
	printCom1 (" Mem2St= %lu byte \n",(unsigned long)coreleft());
	NetStart(); // for TCP IP Test	
	NetInit();

    	//LCD_Clear();	
	//LCD_PutsAt(0,1,"Start1 test COM2 /COM 3",0);
	//RecCOM23();
	
	
	
	   	
	for(b=0;b<7;b++) 
		ClearEEP(b);
		
	for(b=8;b<64;b++)
		ClearEEP(b);
	

	
		

	
	printCom1 (" Mem3= %lu byte \n",(unsigned long)coreleft());
	LCD_PutsAt(0,3,"Start test Key",0);
	LCD_UpdateGraphic();
	do_KeyPAD();
	//Delay(1000);
	
	
	
	printCom1 (" Mem4= %lu byte \n",(unsigned long)coreleft());
	LCD_PutsAt(0,1,"Start TCP test",0);
	while(1)
	{
		doServer();	
		if(ReadCom1()=='q')
		{
			RestoreCom1();
			*LCD_BackLight=0;
			break;
		}
	}
	printCom1 (" Mem5= %lu byte \n",(unsigned long)coreleft());
}
