Exemple #1
0
void MainTask_DeskTop(void)
{
	int i;
	WM_HWIN Win1,Button1,Button2;
	GUI_Init();
	FS_Init();
	AddRelateFile("TXT","文本",_DemoMultiedit);
	AddRelateFile("MP3","音乐",_DemoMp3);
//	ucfs_sim_init();
//	Win1 = WM_CreateWindow(0,0,480,270,WM_CF_SHOW,NULL,0);
	Win1 = WM_CreateWindow(0,0,480,272,WM_CF_SHOW,_cbWindow1,0);	//houhh 20061024...
	
	WM_SelectWindow(Win1);
#if 1
    GUI_SetColor(GUI_WHITE); 
	GUI_SetBkColor(GUI_BLUE);
	GUI_SetFont(&GUI_FontHZ12);		
	GUI_Clear(); 
#endif	
	CreateButton(Win1,pButton,480,272);
	while (1) {
		if (!GUI_Exec())
			GUI_X_ExecIdle();
	}
//	ucfs_sim_deinit();
}
Exemple #2
0
int removeFileOrDirectory(const char* path){
    HFS_SCaner handle = FS_Init(FS_FileType_ALL, 0, NULL, callback_rmFileOrDirectory_directory_end, callback_rmFileOrDirectory_file, callback_rmFileOrDirectory_error);
    FS_Scaner(handle, path, NULL);
    FS_Release(&handle);
    
    return 0;
}
Exemple #3
0
/////////////////////////////////////////////////////////////////////////////
// This hook is called after startup to initialize the application
/////////////////////////////////////////////////////////////////////////////
void APP_Init(void)
{
  s32 i;

  // initialize all LEDs
  MIOS32_BOARD_LED_Init(0xffffffff);

  // MUST be initialized before the SPI functions
  xSPI0Semaphore = xSemaphoreCreateMutex();
  xSDCardSemaphore = xSemaphoreCreateMutex();
  
  // Init filesystem and start SD Card monitoring thread
  FS_Init(0);
  xTaskCreate(TASK_Period1S, (signed portCHAR *)"Period1S", configMINIMAL_STACK_SIZE, NULL, ( tskIDLE_PRIORITY + 4 ), NULL);
  
  // start uIP task
  UIP_TASK_Init(0); 

  // print first message
  print_msg = PRINT_MSG_INIT;
	
  // print welcome message on MIOS terminal
  MIOS32_MIDI_SendDebugMessage("\n");
  MIOS32_MIDI_SendDebugMessage("====================\n");
  MIOS32_MIDI_SendDebugMessage("%s\n", MIOS32_LCD_BOOT_MSG_LINE1);
  MIOS32_MIDI_SendDebugMessage("====================\n");
  MIOS32_MIDI_SendDebugMessage("\n");
}
Exemple #4
0
void MainTask(void) {
  FS_Init();
  while (FS_CheckDisk("", &_aBuffer[0], sizeof(_aBuffer), 5, _OnError) == 1) {
  }
  printf("Finished\n");
  while (1);
}
Exemple #5
0
/*********************************************************************
*
*       MainTask
*/
void MainTask(void) {
  GUI_MOVIE_INFO   Info;
  GUI_MOVIE_HANDLE hMovie;
  int              xSize, ySize;
#ifdef WIN32
  HANDLE           hFile;
  const char       acFileName[] = "C:\\Work\\Grafik\\Video\\FFmpeg\\FFmpeg.emf";
  #define PARAM    &hFile
#else
  FS_FILE        * pFile;
  const char       acFileName[] = "\\FFmpeg.emf";
  #define PARAM    pFile
#endif

  GUI_Init();
  //
  // Get display size
  //
  xSize = LCD_GetXSize();
  ySize = LCD_GetYSize();
  //
  // Create file handle
  //
#ifdef WIN32
  hFile = CreateFile(acFileName, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
#else
  FS_Init();
  pFile = FS_FOpen(acFileName, "r");
#endif
  //
  // Get physical size of movie
  //
  if (GUI_MOVIE_GetInfoEx(_GetData, PARAM, &Info) == 0) {
    //
    // Check if display size fits
    //
    if ((Info.xSize <= xSize) && (Info.ySize <= ySize)) {
      //
      // Create and play movie
      //
      hMovie = GUI_MOVIE_CreateEx(_GetData, PARAM, _cbNotify);
      if (hMovie) {
        GUI_MOVIE_Show(hMovie, (xSize - Info.xSize) / 2, (ySize - Info.ySize) / 2, 1);
      }
    } else {
      //
      // Error message
      //
      GUI_SetFont(GUI_FONT_13_ASCII);
      GUI_DispStringHCenterAt("Video can not be shown.\n\nDisplay size too small.", xSize / 2, (ySize - GUI_GetFontSizeY()) / 2);
    }
  }
  while (1) {
    GUI_Exec();
    GUI_X_Delay(1);
  }
}
Exemple #6
0
/*********************************************************************
*
*       _InitIfRequired
*/
static void _InitIfRequired(void) {
  if (_IsInited == 0) {
    FS_Init();
    FS_FormatLLIfRequired(_sVolumeName);
    //
    // Check if volume needs to be high level formatted.
    //
    if (FS_IsHLFormatted(_sVolumeName) == 0) {
      printf("High level formatting: %s\n", _sVolumeName);
      FS_Format(_sVolumeName, NULL);
    }
    //
    // Enable long file name support if LFN package is available.
    // LFN is an optional emFile package!
    //
//    FS_FAT_SupportLFN();
    _IsInited = 1;
  }
}
/*
====================
SV_Init
====================
*/
void SV_Init (void)
{
	Sys_Printf ("Host_Init\n");

	Memory_Init (host_parms->membase, host_parms->memsize);
	Cbuf_Init ();
	Cmd_Init ();

	COM_Init ();
	FS_Init ();

	PR_Init ();
	Mod_Init ();

	SV_InitNet ();

	SV_InitLocal ();
	Pmove_Init ();

	Hunk_AllocName (0, "-HOST_HUNKLEVEL-");
	host_hunklevel = Hunk_LowMark ();

	Cbuf_InsertText ("exec server.cfg\n");
	Cbuf_Execute ();
	// unlock the early-set cvars after init
	Cvar_UnlockAll ();

	host_initialized = true;

	Con_Printf ("Exe: "__TIME__" "__DATE__"\n");
	Con_Printf ("%4.1f megabyte heap\n", host_parms->memsize/(1024*1024.0));
	Con_Printf ("======== HexenWorld Initialized ========\n");

	// process command line arguments
	Cmd_StuffCmds_f ();
	Cbuf_Execute ();

	// if a map wasn't specified on the command line, spawn demo1.map
	if (sv.state == ss_dead)
		Cmd_ExecuteString ("map demo1", src_command);
	if (sv.state == ss_dead)
		SV_Error ("Couldn't spawn a server");
}
Exemple #8
0
BOOL engine_init(int w, int h) {
    engine = malloc(sizeof(engine_t));
    memset(engine, 0, sizeof(engine_t));

    engine->isRunning = YES;
    engine->renderHeight = h;
    engine->renderWidth = w;

    FS_Init();
    RENDERER_Init(w, h);
    SCRIPTING_Init();
    TEX_Init();
    ENTITY_Init();
    WORLD_Init();
    FONT_Init();

    SCRIPTING_AfterLoaded();

    return YES;
}
Exemple #9
0
void Write_To_SD_Card(const char* fileName, const char* pMode, const void* pData, U32 NumBytes) {
// Remember to add line below to rtcCallBack Function
// Write_To_SD_Card("myData.txt","a",sendBuffer,strlen(sendBuffer));

    NEOMOTE_1_SD_Card_Power_Write(0u); // Power on the SD Card
    
    FS_FILE *  pFile;
    char sdVolName[10];  // Buffer that will hold SD card Volume name
    
    if (0 != FS_GetVolumeName(0, &sdVolName[0], 9)) {
        pFile = FS_FOpen(fileName, pMode);
        if (pFile == 0){
            FS_DeInit();
            FS_Init(); //poipoi debug error
            pFile = FS_FOpen(fileName, pMode);
        }
        FS_Write(pFile, pData, NumBytes);
        FS_FClose(pFile);
    }
    
    NEOMOTE_1_SD_Card_Power_Write(1u); // Power off the SD Card

}
Exemple #10
0
/*
=================
Host_InitCommon
=================
*/
void Host_InitCommon( const char* moduleName, const char* cmdLine, const char *progname, qboolean bChangeGame )
{
	char		dev_level[4];
	char		szTemp[MAX_SYSPATH];
	string		szRootPath;
#ifdef _WIN32
	MEMORYSTATUS	lpBuffer;

	lpBuffer.dwLength = sizeof( MEMORYSTATUS );
	GlobalMemoryStatus( &lpBuffer );
#endif

#ifndef __ANDROID__
	if( !(SDL_GetBasePath()) )
		Sys_Error( "couldn't determine current directory" );

	Q_strncpy(host.rootdir, SDL_GetBasePath(), sizeof(host.rootdir));

	if( host.rootdir[Q_strlen( host.rootdir ) - 1] == '/' )
		host.rootdir[Q_strlen( host.rootdir ) - 1] = 0;
#else
	Q_strncpy(host.rootdir, GAMEPATH, sizeof(host.rootdir));
#endif

#ifdef _WIN32
	host.oldFilter = SetUnhandledExceptionFilter( Sys_Crash );
	host.hInst = GetModuleHandle( NULL );
#endif
	host.change_game = bChangeGame;
	host.state = HOST_INIT; // initialzation started
	host.developer = host.old_developer = 0;

	CRT_Init(); // init some CRT functions

	// some commands may turn engine into infinity loop,
	// e.g. xash.exe +game xash -game xash
	// so we clearing all cmd_args, but leave dbg states as well
	if( cmdLine ) Sys_ParseCommandLine( cmdLine );
#ifdef _WIN32
	SetErrorMode( SEM_FAILCRITICALERRORS );	// no abort/retry/fail errors
#endif

	host.mempool = Mem_AllocPool( "Zone Engine" );

	if( Sys_CheckParm( "-console" )) host.developer = 1;
	if( Sys_CheckParm( "-dev" ))
	{
		if( Sys_GetParmFromCmdLine( "-dev", dev_level ))
		{
			if( Q_isdigit( dev_level ))
				host.developer = abs( Q_atoi( dev_level ));
			else host.developer++; // -dev == 1, -dev -console == 2
		}
		else host.developer++; // -dev == 1, -dev -console == 2
	}

	host.type = HOST_NORMAL; // predict state
	host.con_showalways = true;
#ifdef PANDORA
	if( Sys_CheckParm( "-noshouldermb" )) noshouldermb = 1;
#endif

#ifdef __ANDROID__
	if (chdir(host.rootdir) == 0)
		MsgDev(D_INFO,"%s is working directory now",host.rootdir);
	else
		MsgDev(D_ERROR,"%s is not exists",host.rootdir);
#else
	// we can specified custom name, from Sys_NewInstance
	if( SDL_GetBasePath() && !host.change_game )
	{
		Q_strncpy( szTemp, SDL_GetBasePath(), sizeof(szTemp) );
		FS_FileBase( szTemp, SI.ModuleName );
	}

	if(moduleName) Q_strncpy(SI.ModuleName, moduleName, sizeof(SI.ModuleName));

	FS_ExtractFilePath( SI.ModuleName, szRootPath );
	if( Q_stricmp( host.rootdir, szRootPath ))
	{
		Q_strncpy( host.rootdir, szRootPath, sizeof( host.rootdir ));
#ifdef _WIN32
		SetCurrentDirectory( host.rootdir );
#else
		chdir( host.rootdir );
#endif
	}
#endif

	if( SI.ModuleName[0] == '#' ) host.type = HOST_DEDICATED; 

	// determine host type
	if( progname[0] == '#' )
	{
		Q_strncpy( SI.ModuleName, progname + 1, sizeof( SI.ModuleName ));
		host.type = HOST_DEDICATED;
	}
	else Q_strncpy( SI.ModuleName, progname, sizeof( SI.ModuleName )); 

	if( host.type == HOST_DEDICATED )
	{
		// check for duplicate dedicated server
		host.hMutex = SDL_CreateMutex(  );

		if( !host.hMutex )
		{
			MSGBOX( "Dedicated server already running" );
			Sys_Quit();
			return;
		}

		Sys_MergeCommandLine( cmdLine );

		SDL_DestroyMutex( host.hMutex );
		host.hMutex = SDL_CreateSemaphore( 0 );
		if( host.developer < 3 ) host.developer = 3; // otherwise we see empty console
	}
	else
	{
		// don't show console as default
		if( host.developer < D_WARN ) host.con_showalways = false;
	}

	host.old_developer = host.developer;

	Con_CreateConsole();

	// first text message into console or log 
	MsgDev( D_NOTE, "Sys_LoadLibrary: Loading xash.dll - ok\n" );

	// startup cmds and cvars subsystem
	Cmd_Init();
	Cvar_Init();

	// share developer level across all dlls
	Q_snprintf( dev_level, sizeof( dev_level ), "%i", host.developer );
	Cvar_Get( "developer", dev_level, CVAR_INIT, "current developer level" );
	Cmd_AddCommand( "exec", Host_Exec_f, "execute a script file" );
	Cmd_AddCommand( "memlist", Host_MemStats_f, "prints memory pool information" );

	FS_Init();
	Image_Init();
	Sound_Init();

	FS_LoadGameInfo( NULL );
	Q_strncpy( host.gamefolder, GI->gamefolder, sizeof( host.gamefolder ));


	if( GI->secure )
	{
		// clear all developer levels when game is protected
		Cvar_FullSet( "developer", "0", CVAR_INIT );
		host.developer = host.old_developer = 0;
		host.con_showalways = false;
	}

	HPAK_Init();

	IN_Init();
	Key_Init();
}
Exemple #11
0
/*
====================
Host_Init
====================
*/
static void Host_Init (void)
{
	int i;
	const char* os;
	char vabuf[1024];

	if (COM_CheckParm("-profilegameonly"))
		Sys_AllowProfiling(false);

	// LordHavoc: quake never seeded the random number generator before... heh
	if (COM_CheckParm("-benchmark"))
		srand(0); // predictable random sequence for -benchmark
	else
		srand((unsigned int)time(NULL));

	// FIXME: this is evil, but possibly temporary
	// LordHavoc: doesn't seem very temporary...
	// LordHavoc: made this a saved cvar
// COMMANDLINEOPTION: Console: -developer enables warnings and other notices (RECOMMENDED for mod developers)
	if (COM_CheckParm("-developer"))
	{
		developer.value = developer.integer = 1;
		developer.string = "1";
	}

	if (COM_CheckParm("-developer2") || COM_CheckParm("-developer3"))
	{
		developer.value = developer.integer = 1;
		developer.string = "1";
		developer_extra.value = developer_extra.integer = 1;
		developer_extra.string = "1";
		developer_insane.value = developer_insane.integer = 1;
		developer_insane.string = "1";
		developer_memory.value = developer_memory.integer = 1;
		developer_memory.string = "1";
		developer_memorydebug.value = developer_memorydebug.integer = 1;
		developer_memorydebug.string = "1";
	}

	if (COM_CheckParm("-developer3"))
	{
		gl_paranoid.integer = 1;gl_paranoid.string = "1";
		gl_printcheckerror.integer = 1;gl_printcheckerror.string = "1";
	}

// COMMANDLINEOPTION: Console: -nostdout disables text output to the terminal the game was launched from
	if (COM_CheckParm("-nostdout"))
		sys_nostdout = 1;

	// used by everything
	Memory_Init();

	// initialize console command/cvar/alias/command execution systems
	Cmd_Init();

	// initialize memory subsystem cvars/commands
	Memory_Init_Commands();

	// initialize console and logging and its cvars/commands
	Con_Init();

	// initialize various cvars that could not be initialized earlier
	u8_Init();
	Curl_Init_Commands();
	Cmd_Init_Commands();
	Sys_Init_Commands();
	COM_Init_Commands();
	FS_Init_Commands();

	// initialize console window (only used by sys_win.c)
	Sys_InitConsole();

	// initialize the self-pack (must be before COM_InitGameType as it may add command line options)
	FS_Init_SelfPack();

	// detect gamemode from commandline options or executable name
	COM_InitGameType();

	// construct a version string for the corner of the console
	os = DP_OS_NAME;
	dpsnprintf (engineversion, sizeof (engineversion), "%s %s %s", gamename, os, buildstring);
	Con_Printf("%s\n", engineversion);

	// initialize process nice level
	Sys_InitProcessNice();

	// initialize ixtable
	Mathlib_Init();

	// initialize filesystem (including fs_basedir, fs_gamedir, -game, scr_screenshot_name)
	FS_Init();

	// register the cvars for session locking
	Host_InitSession();

	// must be after FS_Init
	Crypto_Init();
	Crypto_Init_Commands();

	NetConn_Init();
	Curl_Init();
	//PR_Init();
	//PR_Cmd_Init();
	PRVM_Init();
	Mod_Init();
	World_Init();
	SV_Init();
	V_Init(); // some cvars needed by server player physics (cl_rollangle etc)
	Host_InitCommands();
	Host_InitLocal();
	Host_ServerOptions();

	Thread_Init();

	if (cls.state == ca_dedicated)
		Cmd_AddCommand ("disconnect", CL_Disconnect_f, "disconnect from server (or disconnect all clients if running a server)");
	else
	{
		Con_DPrintf("Initializing client\n");

		R_Modules_Init();
		Palette_Init();
#ifdef CONFIG_MENU
		MR_Init_Commands();
#endif
		VID_Shared_Init();
		VID_Init();
		Render_Init();
		S_Init();
		CDAudio_Init();
		Key_Init();
		CL_Init();
	}

	// save off current state of aliases, commands and cvars for later restore if FS_GameDir_f is called
	// NOTE: menu commands are freed by Cmd_RestoreInitState
	Cmd_SaveInitState();

	// FIXME: put this into some neat design, but the menu should be allowed to crash
	// without crashing the whole game, so this should just be a short-time solution

	// here comes the not so critical stuff
	if (setjmp(host_abortframe)) {
		return;
	}

	Host_AddConfigText();
	Cbuf_Execute();

	// if stuffcmds wasn't run, then quake.rc is probably missing, use default
	if (!host_stuffcmdsrun)
	{
		Cbuf_AddText("exec default.cfg\nexec " CONFIGFILENAME "\nexec autoexec.cfg\nstuffcmds\n");
		Cbuf_Execute();
	}

	// put up the loading image so the user doesn't stare at a black screen...
	SCR_BeginLoadingPlaque(true);

#ifdef CONFIG_MENU
	if (cls.state != ca_dedicated)
	{
		MR_Init();
	}
#endif

	// check for special benchmark mode
// COMMANDLINEOPTION: Client: -benchmark <demoname> runs a timedemo and quits, results of any timedemo can be found in gamedir/benchmark.log (for example id1/benchmark.log)
	i = COM_CheckParm("-benchmark");
	if (i && i + 1 < com_argc)
	if (!sv.active && !cls.demoplayback && !cls.connect_trying)
	{
		Cbuf_AddText(va(vabuf, sizeof(vabuf), "timedemo %s\n", com_argv[i + 1]));
		Cbuf_Execute();
	}

	// check for special demo mode
// COMMANDLINEOPTION: Client: -demo <demoname> runs a playdemo and quits
	i = COM_CheckParm("-demo");
	if (i && i + 1 < com_argc)
	if (!sv.active && !cls.demoplayback && !cls.connect_trying)
	{
		Cbuf_AddText(va(vabuf, sizeof(vabuf), "playdemo %s\n", com_argv[i + 1]));
		Cbuf_Execute();
	}

// COMMANDLINEOPTION: Client: -capturedemo <demoname> captures a playdemo and quits
	i = COM_CheckParm("-capturedemo");
	if (i && i + 1 < com_argc)
	if (!sv.active && !cls.demoplayback && !cls.connect_trying)
	{
		Cbuf_AddText(va(vabuf, sizeof(vabuf), "playdemo %s\ncl_capturevideo 1\n", com_argv[i + 1]));
		Cbuf_Execute();
	}

	if (cls.state == ca_dedicated || COM_CheckParm("-listen"))
	if (!sv.active && !cls.demoplayback && !cls.connect_trying)
	{
		Cbuf_AddText("startmap_dm\n");
		Cbuf_Execute();
	}

	if (!sv.active && !cls.demoplayback && !cls.connect_trying)
	{
#ifdef CONFIG_MENU
		Cbuf_AddText("togglemenu 1\n");
#endif
		Cbuf_Execute();
	}

	Con_DPrint("========Initialized=========\n");

	//Host_StartVideo();

	if (cls.state != ca_dedicated)
		SV_StartThread();
}
Exemple #12
0
/*
* Qcommon_Init
*/
void Qcommon_Init( int argc, char **argv )
{
	if( setjmp( abortframe ) )
		Sys_Error( "Error during initialization: %s", com_errormsg );

	QThreads_Init();

	com_print_mutex = QMutex_Create();

	// initialize memory manager
	Memory_Init();

	// prepare enough of the subsystems to handle
	// cvar and command buffer management
	COM_InitArgv( argc, argv );

	Cbuf_Init();

	// initialize cmd/cvar/dynvar tries
	Cmd_PreInit();
	Cvar_PreInit();
	Dynvar_PreInit();

	// create basic commands and cvars
	Cmd_Init();
	Cvar_Init();
	Dynvar_Init();
	dynvars_initialized = qtrue;

	wswcurl_init();

	Key_Init();

	// we need to add the early commands twice, because
	// a basepath or cdpath needs to be set before execing
	// config files, but we want other parms to override
	// the settings of the config files
	Cbuf_AddEarlyCommands( qfalse );
	Cbuf_Execute();

	// wsw : aiwa : create dynvars (needs to be completed before .cfg scripts are executed)
	Dynvar_Create( "sys_uptime", qtrue, Com_Sys_Uptime_f, DYNVAR_READONLY );
	Dynvar_Create( "frametick", qfalse, DYNVAR_WRITEONLY, DYNVAR_READONLY );
	Dynvar_Create( "quit", qfalse, DYNVAR_WRITEONLY, DYNVAR_READONLY );
	Dynvar_Create( "irc_connected", qfalse, Irc_GetConnected_f, Irc_SetConnected_f );

	Sys_InitDynvars();
	CL_InitDynvars();

#ifdef TV_SERVER_ONLY
	tv_server = Cvar_Get( "tv_server", "1", CVAR_NOSET );
	Cvar_ForceSet( "tv_server", "1" );
#else
	tv_server = Cvar_Get( "tv_server", "0", CVAR_NOSET );
#endif

#ifdef DEDICATED_ONLY
	dedicated =	    Cvar_Get( "dedicated", "1", CVAR_NOSET );
	Cvar_ForceSet( "dedicated", "1" );
#else
	dedicated =	    Cvar_Get( "dedicated", "0", CVAR_NOSET );
#endif

#ifdef MATCHMAKER
	mm_server =	    Cvar_Get( "mm_server", "1", CVAR_READONLY );
	Cvar_ForceSet( "mm_server", "1" );
#else
	mm_server =	    Cvar_Get( "mm_server", "0", CVAR_READONLY );
#endif

	FS_Init();

	Cbuf_AddText( "exec default.cfg\n" );
	if( !dedicated->integer )
	{
		Cbuf_AddText( "exec config.cfg\n" );
		Cbuf_AddText( "exec autoexec.cfg\n" );
	}
	else if( mm_server->integer )
	{
		Cbuf_AddText( "exec mmaker_autoexec.cfg\n" );
	}
	else if( tv_server->integer )
	{
		Cbuf_AddText( "exec tvserver_autoexec.cfg\n" );
	}
	else
	{
		Cbuf_AddText( "exec dedicated_autoexec.cfg\n" );
	}

	Cbuf_AddEarlyCommands( qtrue );
	Cbuf_Execute();

	//
	// init commands and vars
	//
	Memory_InitCommands();

	Qcommon_InitCommands();

	host_speeds =	    Cvar_Get( "host_speeds", "0", 0 );
	log_stats =	    Cvar_Get( "log_stats", "0", 0 );
	developer =	    Cvar_Get( "developer", "0", 0 );
	timescale =	    Cvar_Get( "timescale", "1.0", CVAR_CHEAT );
	fixedtime =	    Cvar_Get( "fixedtime", "0", CVAR_CHEAT );
	if( tv_server->integer )
		logconsole =	    Cvar_Get( "logconsole", "tvconsole.log", CVAR_ARCHIVE );
	else if( dedicated->integer )
		logconsole =	    Cvar_Get( "logconsole", "wswconsole.log", CVAR_ARCHIVE );
	else
		logconsole =	    Cvar_Get( "logconsole", "", CVAR_ARCHIVE );
	logconsole_append = Cvar_Get( "logconsole_append", "1", CVAR_ARCHIVE );
	logconsole_flush =  Cvar_Get( "logconsole_flush", "0", CVAR_ARCHIVE );
	logconsole_timestamp =	Cvar_Get( "logconsole_timestamp", "0", CVAR_ARCHIVE );

	com_showtrace =	    Cvar_Get( "com_showtrace", "0", 0 );
	com_introPlayed3 =   Cvar_Get( "com_introPlayed3", "0", CVAR_ARCHIVE );

	Cvar_Get( "irc_server", "irc.quakenet.org", CVAR_ARCHIVE );
	Cvar_Get( "irc_port", "6667", CVAR_ARCHIVE );
	Cvar_Get( "irc_nick", APPLICATION "Player", CVAR_ARCHIVE );
	Cvar_Get( "irc_user", APPLICATION "User", CVAR_ARCHIVE );
	Cvar_Get( "irc_password", "", CVAR_ARCHIVE );

	Cvar_Get( "gamename", APPLICATION, CVAR_READONLY );
	versioncvar = Cvar_Get( "version", APP_VERSION_STR " " CPUSTRING " " __DATE__ " " BUILDSTRING, CVAR_SERVERINFO|CVAR_READONLY );
	revisioncvar = Cvar_Get( "revision", SVN_RevString(), CVAR_READONLY );

	Sys_Init();

	NET_Init();
	Netchan_Init();

	CM_Init();

	Steam_LoadLibrary();

	Com_ScriptModule_Init();

	MM_Init();

	SV_Init();
	CL_Init();

	SCR_EndLoadingPlaque();

	if( !dedicated->integer )
	{
		Cbuf_AddText( "exec stuffcmds.cfg\n" );
	}
	else if( mm_server->integer )
	{
		Cbuf_AddText( "exec mmaker_stuffcmds.cfg\n" );
	}
	else if( tv_server->integer )
	{
		Cbuf_AddText( "exec tvserver_stuffcmds.cfg\n" );
	}
	else
	{
		Cbuf_AddText( "exec dedicated_stuffcmds.cfg\n" );
	}

	// add + commands from command line
	if( !Cbuf_AddLateCommands() )
	{
		// if the user didn't give any commands, run default action

		if( !dedicated->integer )
		{
			// only play the introduction sequence once
			if( !com_introPlayed3->integer )
			{
				Cvar_ForceSet( com_introPlayed3->name, "1" );
#if !defined(__MACOSX__) && !defined(__ANDROID__)
				Cbuf_AddText( "cinematic intro.roq\n" );
#endif
			}
		}
	}
	else
	{
		// the user asked for something explicit
		// so drop the loading plaque
		SCR_EndLoadingPlaque();
	}

	Com_Printf( "\n====== %s Initialized ======\n", APPLICATION );

	Cbuf_Execute();
}
Exemple #13
0
int main(void)
{
	gfxInitDefault();
	consoleInitDefault();

	Result ret;
	state = STATE_START;

	ret = FS_Init();
	if (R_FAILED(ret))
	{
		consoleLog("\nCouldn't initialize the FS module!\n");
		consoleLog("Have you selected a title?\n");
		consoleLog("Error code: 0x%lx\n", ret);
		// state = STATE_ERROR; // TODO: Remove out of Citra
	}

	ret = saveInit();
	if (R_FAILED(ret))
	{
		consoleLog("\nCouldn't initialize the Save module!\n");
		consoleLog("Error code: 0x%lx\n", ret);
		// state = STATE_ERROR; // TODO: Remove out of Citra
	}

	ret = saveGetTitleId(&titleid);
	if (R_FAILED(ret))
	{
		consoleLog("\nCouldn't get the title id of the game!\n");
		consoleLog("Error code: 0x%lx\n", ret);
		// state = STATE_ERROR; // TODO: Remove out of Citra
	}

	fsDirInit();
	fsBackInit(titleid);
	switchState(&state);
	consoleSelectNew(&consoleLog);

	drawHelp();

	u64 heldUp = 0;
	u64 heldDown = 0;
	u32 kDown, kHeld;
	while (aptMainLoop())
	{
		gspWaitForVBlank();
		hidScanInput();

		kDown = hidKeysDown();
		kHeld = hidKeysHeld();

		switch (state)
		{
			case STATE_BROWSE:
			{
				if (kDown & (KEY_LEFT | KEY_RIGHT))
				{
					fsDirSwitch(NULL);
					fsDirPrintSave();
					fsDirPrintSdmc();
				}

				if (kDown & KEY_ZL)
				{
					fsDirSwitch(&saveDir);
					fsDirPrintSave();
					fsDirPrintSdmc();
				}

				if (kDown & KEY_ZR)
				{
					fsDirSwitch(&sdmcDir);
					fsDirPrintSave();
					fsDirPrintSdmc();
				}

				if (kDown & KEY_UP)
				{
					fsDirMove(-1);
					fsDirPrintCurrent();
					heldUp = svcGetSystemTick() + HELD_TICK * 2;
				}
#ifndef NO_HELD_TICK
				else if (kHeld & KEY_UP)
				{
					if (heldUp + HELD_TICK < svcGetSystemTick())
					{
						fsDirMove(-1);
						fsDirPrintCurrent();
						heldUp = svcGetSystemTick();
					}
				}
#endif

				if (kDown & KEY_DOWN)
				{
					fsDirMove(+1);
					fsDirPrintCurrent();
					heldDown = svcGetSystemTick() + HELD_TICK * 2;
				}
#ifndef NO_HELD_TICK
				else if (kHeld & KEY_DOWN)
				{
					if (heldDown + HELD_TICK < svcGetSystemTick())
					{
						fsDirMove(+1);
						fsDirPrintCurrent();
						heldDown = svcGetSystemTick();
					}
				}
#endif

				if (kDown & KEY_A)
				{
					ret = fsDirGotoSubDir();
					consoleLog("   > fsDirGotoSubDir: %lx\n", ret);
					fsDirPrintCurrent();
				}

				if (kDown & KEY_B)
				{
					ret = fsDirGotoParentDir();
					consoleLog("   > fsDirGotoParentDir: %lx\n", ret);
					fsDirPrintCurrent();
				}

				if (kDown & KEY_X)
				{
					ret = fsDirDeleteCurrentEntry();
					consoleLog("   > fsDirDeleteCurrentEntry: %lx\n", ret);
					fsDirPrintCurrent();
				}

				if (kDown & KEY_Y)
				{
					ret = fsDirCopyCurrentEntry(false);
					consoleLog("   > fsDirCopyCurrentEntry: %lx\n", ret);
					fsDirPrintDick();
				}

				break;
			}
			case STATE_BACKUP:
			{
				if (kDown & KEY_A)
				{
					ret = fsBackImport();
					consoleLog("  > fsBackImport: %lx\n", ret);
					fsBackPrintSave();
				}

				if (kDown & KEY_B)
				{
					state = STATE_BACKUP_KEY;

					// TODO: setKeyboardString

					consoleSelectNew(&logConsole);
				}

				if (kDown & KEY_X)
				{
					ret = fsBackDelete();
					consoleLog("  > fsBackDelete: %lx\n", ret);
					fsBackPrintBackup();
				}

				if (kDown & KEY_Y)
				{
					ret = fsBackExport();
					consoleLog("  > fsBackExport: %lx\n", ret);
					fsBackPrintBackup();
				}

				if (kDown & KEY_UP)
				{
					fsBackMove(-1);
					fsBackPrintBackup();
					heldUp = svcGetSystemTick() + HELD_TICK * 2;
				}
#ifndef NO_HELD_TICK
				else if (kHeld & KEY_UP)
				{
					if (heldUp + HELD_TICK < svcGetSystemTick())
					{
						fsBackMove(-1);
						fsBackPrintBackup();
						heldUp = svcGetSystemTick();
					}
				}
#endif

				if (kDown & KEY_DOWN)
				{
					fsBackMove(+1);
					fsBackPrintBackup();
					heldDown = svcGetSystemTick() + HELD_TICK * 2;
				}
#ifndef NO_HELD_TICK
				else if (kHeld & KEY_DOWN)
				{
					if (heldDown + HELD_TICK < svcGetSystemTick())
					{
						fsBackMove(+1);
						fsBackPrintBackup();
						heldDown = svcGetSystemTick();
					}
				}
#endif

				break;
			}
			case STATE_BACKUP_KEY:
			{
				// TODO: updateKeyboard

				if (kDown & KEY_A)
				{
					state = STATE_BACKUP;

					// TODO: getKeyboardString

					drawBackup();
				}

				if (kDown & KEY_B)
				{
					state = STATE_BACKUP;
					drawBackup();
				}

				break;
			}
			case STATE_ERROR:
			{
				consoleLog("\nAn error has occured...\n");
				consoleLog("Please check previous logs!\n");
				consoleLog("\nPress start to exit.\n");
				state = STATE_EOF;
				break;
			}
			default: break;
		}

		{
			if (kDown & KEY_L)
			{
				// TODO: Prev
				switchState(&state);
			}

			if (kDown & KEY_R)
			{
				// TODO: Next
				switchState(&state);
			}

			if (kDown & KEY_SELECT)
			{
				drawHelp();
			}
		}

		if (kDown & KEY_START)
			break;

		gfxFlushBuffers();
		gfxSwapBuffers();
	}

	fsDirExit();
	fsBackExit();
	FS_Exit();
	{
		hidScanInput();
		if (!(hidKeysHeld() & KEY_L) && !(hidKeysHeld() & KEY_R))
		{
			u8 out = 0;
			FS_MediaType mediaType = 3;
			FSUSER_GetMediaType(&mediaType);
			Result ret = saveRemoveSecureValue(titleid, mediaType, &out);
			if (R_FAILED(ret))
			{
				consoleSelect(&logConsole);
				printf("\nSecure value not removed.\n");
				printf("It might already be unitialized.\n");
				printf("Error code: 0x%lx (%i)\n", ret, out);
				printf("\n\nPress any key to exit.\n");
				waitKey(KEY_ANY);
			}
		}
	}
	gfxExit();
	return 0;
}
Exemple #14
0
int main(void)
{
	Result ret = 0, error = 0;

	sf2d_init();
	sftd_init();
	romfsInit();

	srand(osGetTime());

	// consoleInit(GFX_TOP, NULL); // TODO: Comment it!
	// consoleInit(GFX_BOTTOM, NULL); // TODO: Comment it!

	printf("> Loading texture manager\n");
	PHBanku::texture = new TextureManager();
	ret = PHBanku::texture->load();
	if (R_FAILED(ret))
	{
		// Graphics
		error |= ERR_GRAPHICS;
	}

	printf("> Loading font manager\n");
	PHBanku::font = new FontManager();
	ret = PHBanku::font->load();
	if (R_FAILED(ret))
	{
		// Font
		error |= ERR_FONT;
	}

	printf("> Loading data manager\n");
	PHBanku::data = new DataManager();
	ret = PHBanku::data->load();
	if (R_FAILED(ret))
	{
		// Data
		error |= ERR_DATA;
	}

#ifdef __cia
	printf("> Starting title selector\n");
	while (!error && TS_Loop())
	{

	// Draw the static loading screen again because of ts.h
	PHBanku::texture->drawStaticLoadingScreen();

	printf("> Loading filesystem services\n");
	ret = FSCIA_Init(titleEntry.titleid, titleEntry.mediatype);
	if (R_FAILED(ret))
	{
		// Filesystem
		error |= ERR_FILESYSTEM;
	}
#else // __3dsx
	printf("> Loading filesystem services\n");
	ret = FS_Init();
	if (R_FAILED(ret))
	{
		// Filesystem
		error |= ERR_FILESYSTEM;
	}
#endif

	printf("> Loading save manager\n");
	PHBanku::save = new SaveManager();
	ret = PHBanku::save->load();
	if (R_FAILED(ret))
	{
		// Save
		error |= ERR_SAVE;
	}

	if (!error)
	{
		printf("> Starting box viewer...\n");
		Viewer* viewer = new BoxViewer();

		ViewState state = Viewer::startMainLoop(viewer);

		if (state == ViewState::Saving)
		{
			// TODO Remove when better save display!
			consoleInit(GFX_TOP, NULL);
			printf("Saving...\n");
			// ^

			PHBanku::save->save();
		}
		else
		{
			// TODO Remove when better exit display!
			consoleInit(GFX_TOP, NULL);
			printf("Exiting...\n");
			// ^
		}

		delete viewer;
	}

	delete PHBanku::save;

#ifdef __cia
	FSCIA_Exit();
	consoleExit(GFX_TOP, NULL);
	break; // TODO Remove! The app crash itself after the 2nd ts, unknown cause.
	} // while (TS_LOOP())

	if (!error)
	{
		// TODO Remove when better exit display!
		consoleInit(GFX_BOTTOM, NULL);
		// ^

		printf("\nThe app execution ended!\n");
		printf("Thanks for being awesome!\n");
	}
#else
	FS_Exit();
#endif

	if (error)
	{
		// TODO Remove when better error display!
		consoleInit(GFX_TOP, NULL);
		// ^

		printf("\nProblem happened: 0x%lx\n", error);
		if (error & ERR_SAVE) printf(" \a Save\n");
		if (error & ERR_DATA) printf(" \a Data\n");
		if (error & ERR_FONT) printf(" \a Font\n");
		if (error & ERR_GRAPHICS) printf(" \a Graphics\n");
		if (error & ERR_FILESYSTEM) printf(" \a Filesystem\n");
		printf("PHBank version: %08x\n", VERSION);
		printf("Can't start the viewer.\n");
		printf("Press any key to exit\n");
		waitKey(KEY_ANY);
	}

	delete PHBanku::data;
	delete PHBanku::font;
	delete PHBanku::texture;

	romfsExit();
	sftd_fini();
	sf2d_fini();
	return 0;
}
Exemple #15
0
static void SetupHardware( void )
{
    u8 buf[32];
#if 0//debug by karlno
    u8 *ptr1,*ptr2,*ptr3,*ptr4;
#endif

    GPIO_Config();//针对gpio的一些配置
    NVIC_Config();//针对中断向量的一些配置
    EXTI_Config();//外部中断配置

#if 0//debug by karlno
    Debug("#### 123\n\r");

    ptr1=Q_Mallco(200);
    ptr2=Q_Mallco(68);

    Q_Free(ptr1);
    ptr3=Q_Mallco(68);

    ptr3=Q_Mallco(68);

    while(1);
#endif


    Debug("\n\n\n\r************************************\n\r");
    Debug("* Q-SYS %s               *\n\r",QSYS_VERSION);
    Debug("* Start up our dreams!             *\n\r");
#if OS_USE_FREERTOS
    Debug("* Base on FreeRTOS                 *\n\r");
#elif OS_USE_UCOS
    Debug("* Base on uC/OS                    *\n\r");
#endif
    Debug("* Hardware PID : %d %d           *\n\r",QXW_PRODUCT_ID,QXW_LCM_ID);
    Debug("* Hardware ID : %X           *\n\r",GetHwID());
    Debug("* Www.Q-ShareWe.Com                *\n\r");
    Debug("************************************\n\r\n\r");

    M25P16_Init();//spi flash

    M25P16_Read_Id(buf);
    Debug("SPI Flash ID:\n\r");
    DisplayBuf(buf,20,8);
    Debug("\n\r");

    SPI_Touch_Init();//触摸屏

    VsInit();//Vs1003的配置

    //sd卡文件系统初始化
    if(disk_initialize(0))
    {
        Debug("Disk Initialize error!\n\r");
    }
    else
    {
        Debug("Disk Initialize OK!\n\r");
#if 0//debug
        {
            FIL fsrc;            // file objects
            FRESULT res;         // FatFs function common result code
            UINT br;
            u8 *p=Q_Mallco(1024);
            u32 time=QW_GetNowTimeMs();


            res = f_mount(0,&FS);	//  初始化分区结构,它不初始化SD卡
            if(res == FR_OK)
            {
                Debug("\n\nATA mounrt OK, fs_type =  %d\n\r",FS.fs_type);
            }
            else
            {
                Debug("\nATA mounrt Error!!!\n%d\n\r",res);
            }

            res = f_open(&fsrc,"1.rar",FA_READ) ;
            Debug("Open %d\n\r",res);
            while(1)
            {
                res = f_read(&fsrc,p,fsrc.fsize,&br); //  读文件数据,长度file.fsize,
                if(br==0)break;
            }
            f_close(&fsrc);
            Debug("Time Gap:%d\n\r",QW_GetNowTimeMs()-time);
            while(1);
        }
#endif
        FS_Init();
        Debug("File system mount OK!\n\r");
        Q_DB_SetStatus(Status_FsInitFinish,TRUE,NULL,0);
    }

    Adc_Init();

    Tim2_Init();//用户定时器
    Tim3_Init();//背光pwm初始化
    Tim4_Init();//用户定时器
    Tim5_Init();//用户定时器

    USB_SetHw();
    USB_Init();
}
Exemple #16
0
/*
=================
Qcommon_Init
=================
*/
void Qcommon_Init(int argc, char **argv)
{
    if (setjmp(abortframe))
        Sys_Error("Error during initialization: %s", com_errorMsg);

    com_argc = argc;
    com_argv = argv;

    Com_SetLastError(NULL);

    X86_SetFPCW();

    // prepare enough of the subsystems to handle
    // cvar and command buffer management
    Z_Init();
    MSG_Init();
    Cbuf_Init();
    Cmd_Init();
    Cvar_Init();
    Key_Init();
    Prompt_Init();
    Con_Init();

    //
    // init commands and vars
    //
    z_perturb = Cvar_Get("z_perturb", "0", 0);
#if USE_CLIENT
    host_speeds = Cvar_Get("host_speeds", "0", 0);
#endif
#ifdef _DEBUG
    developer = Cvar_Get("developer", "0", 0);
#endif
    timescale = Cvar_Get("timescale", "1", CVAR_CHEAT);
    fixedtime = Cvar_Get("fixedtime", "0", CVAR_CHEAT);
    logfile_enable = Cvar_Get("logfile", "0", 0);
    logfile_flush = Cvar_Get("logfile_flush", "0", 0);
    logfile_name = Cvar_Get("logfile_name", "console", 0);
    logfile_prefix = Cvar_Get("logfile_prefix", "[%Y-%m-%d %H:%M] ", 0);
#if USE_CLIENT
    dedicated = Cvar_Get("dedicated", "0", CVAR_NOSET);
    cl_running = Cvar_Get("cl_running", "0", CVAR_ROM);
    cl_paused = Cvar_Get("cl_paused", "0", CVAR_ROM);
#else
    dedicated = Cvar_Get("dedicated", "1", CVAR_ROM);
#endif
    sv_running = Cvar_Get("sv_running", "0", CVAR_ROM);
    sv_paused = Cvar_Get("sv_paused", "0", CVAR_ROM);
    com_timedemo = Cvar_Get("timedemo", "0", CVAR_CHEAT);
    com_date_format = Cvar_Get("com_date_format", "%Y-%m-%d", 0);
#ifdef _WIN32
    com_time_format = Cvar_Get("com_time_format", "%H.%M", 0);
#else
    com_time_format = Cvar_Get("com_time_format", "%H:%M", 0);
#endif
#ifdef _DEBUG
    com_debug_break = Cvar_Get("com_debug_break", "0", 0);
#endif
    com_fatal_error = Cvar_Get("com_fatal_error", "0", 0);
    com_version = Cvar_Get("version", com_version_string, CVAR_SERVERINFO | CVAR_ROM);

    allow_download = Cvar_Get("allow_download", COM_DEDICATED ? "0" : "1", CVAR_ARCHIVE);
    allow_download_players = Cvar_Get("allow_download_players", "1", CVAR_ARCHIVE);
    allow_download_models = Cvar_Get("allow_download_models", "1", CVAR_ARCHIVE);
    allow_download_sounds = Cvar_Get("allow_download_sounds", "1", CVAR_ARCHIVE);
    allow_download_maps = Cvar_Get("allow_download_maps", "1", CVAR_ARCHIVE);
    allow_download_textures = Cvar_Get("allow_download_textures", "1", CVAR_ARCHIVE);
    allow_download_pics = Cvar_Get("allow_download_pics", "1", CVAR_ARCHIVE);
    allow_download_others = Cvar_Get("allow_download_others", "0", 0);

    rcon_password = Cvar_Get("rcon_password", "", CVAR_PRIVATE);

    Cmd_AddCommand("z_stats", Z_Stats_f);

    //Cmd_AddCommand("setenv", Com_Setenv_f);

    Cmd_AddMacro("com_date", Com_Date_m);
    Cmd_AddMacro("com_time", Com_Time_m);
    Cmd_AddMacro("com_uptime", Com_Uptime_m);
    Cmd_AddMacro("com_uptime_long", Com_UptimeLong_m);
    Cmd_AddMacro("random", Com_Random_m);
    Cmd_AddMacro("com_maplist", Com_MapList_m);

    // add any system-wide configuration files
    Sys_AddDefaultConfig();

    // we need to add the early commands twice, because
    // a basedir or cddir needs to be set before execing
    // config files, but we want other parms to override
    // the settings of the config files
    Com_AddEarlyCommands(qfalse);

    Sys_Init();

    Sys_RunConsole();

    FS_Init();

    Sys_RunConsole();

    // no longer allow CVAR_NOSET modifications
    com_initialized = qtrue;

    // after FS is initialized, open logfile
    logfile_enable->changed = logfile_enable_changed;
    logfile_flush->changed = logfile_param_changed;
    logfile_name->changed = logfile_param_changed;
    logfile_enable_changed(logfile_enable);

    // execute configs: default.cfg may come from the packfile, but config.cfg
    // and autoexec.cfg must be real files within the game directory
    Com_AddConfigFile(COM_DEFAULT_CFG, 0);
    Com_AddConfigFile(COM_CONFIG_CFG, FS_TYPE_REAL | FS_PATH_GAME);
    Com_AddConfigFile(COM_AUTOEXEC_CFG, FS_TYPE_REAL | FS_PATH_GAME);
    Com_AddConfigFile(COM_POSTEXEC_CFG, FS_TYPE_REAL);

    Com_AddEarlyCommands(qtrue);

    Cmd_AddCommand("lasterror", Com_LastError_f);

    Cmd_AddCommand("quit", Com_Quit_f);
#if !USE_CLIENT
    Cmd_AddCommand("recycle", Com_Recycle_f);
#endif

    srand(Sys_Milliseconds());

    Netchan_Init();
    NET_Init();
    BSP_Init();
    CM_Init();
    SV_Init();
    CL_Init();
    TST_Init();

    Sys_RunConsole();

    // add + commands from command line
    if (!Com_AddLateCommands()) {
        // if the user didn't give any commands, run default action
        char *cmd = COM_DEDICATED ? "dedicated_start" : "client_start";

        if ((cmd = Cmd_AliasCommand(cmd)) != NULL) {
            Cbuf_AddText(&cmd_buffer, cmd);
            Cbuf_Execute(&cmd_buffer);
        }
    } else {
        // the user asked for something explicit
        // so drop the loading plaque
        SCR_EndLoadingPlaque();
    }

    // even not given a starting map, dedicated server starts
    // listening for rcon commands (create socket after all configs
    // are executed to make sure port number is properly set)
    if (COM_DEDICATED) {
        NET_Config(NET_SERVER);
    }

    Com_AddConfigFile(COM_POSTINIT_CFG, FS_TYPE_REAL);

    Com_Printf("====== " PRODUCT " initialized ======\n\n");
    Com_LPrintf(PRINT_NOTICE, APPLICATION " " VERSION ", " __DATE__ "\n");
    Com_Printf("http://skuller.net/q2pro/\n\n");

    time(&com_startTime);

    com_eventTime = Sys_Milliseconds();
}
Exemple #17
0
int main() {

    Init();
#ifndef ENABLE_MODULAR
    //Banner();
#endif
    if(PWR_CheckPowerSwitch()) PWR_Shutdown();

    LCD_Clear(0x0000);
#ifdef TEST_ADC
    ADC_ScanChannels(); while(1);
#endif
    u32 buttons = ScanButtons();
    if (CHAN_ButtonIsPressed(buttons, BUT_ENTER) || !FS_Init()) {
        LCD_DrawUSBLogo(LCD_WIDTH, LCD_HEIGHT);
        USB_Connect();
        LCD_Clear(0x0000);
        FS_Init();
    }

    CONFIG_LoadTx();
    SPI_ProtoInit();
    CONFIG_ReadDisplay();
    CONFIG_ReadModel(CONFIG_GetCurrentModel());
    CONFIG_ReadLang(Transmitter.language);

    BACKLIGHT_Brightness(Transmitter.backlight);
    LCD_Contrast(Transmitter.contrast);
    LCD_SetFont(DEFAULT_FONT.font);
    LCD_SetFontColor(DEFAULT_FONT.font_color);

    GUI_HandleButtons(1);

    MIXER_Init();
    PAGE_Init();

    CLOCK_StartWatchdog();

#if HAS_DATALOG
    DATALOG_Init();
#endif

    priority_ready = 0;
    CLOCK_SetMsecCallback(LOW_PRIORITY, LOW_PRIORITY_MSEC);
    CLOCK_SetMsecCallback(MEDIUM_PRIORITY, MEDIUM_PRIORITY_MSEC);

    // We need to wait until we've actually measured the ADC before proceeding
    while(! (priority_ready & (1 << LOW_PRIORITY)))
        PWR_Sleep();

    //Only do this after we've initialized all channel data so the saftey works
    PROTOCOL_InitModules();
    GUI_DrawScreen();

    // Add startup delay to make sure audio player is initialized
    // AUDIO_Init() has already been called by CONFIG_ReadModel()
#if HAS_EXTENDED_AUDIO
    audio_queue_time = CLOCK_getms() + 1500;
    num_audio=1;
    next_audio=1;
#if (LCD_WIDTH == 480) || (LCD_WIDTH == 320)
    if(Display.background.drawn_background)
        while(CLOCK_getms() < audio_queue_time - 1200);
#endif
    AUDIO_SetVolume(); // Initial setting of voice volume
#endif

    MUSIC_Play(MUSIC_STARTUP);

#ifdef HAS_EVENT_LOOP
    start_event_loop();
#else
    while(1) {
        if(priority_ready) {
            EventLoop();
        }
        //This does not appear to have any impact on power
        //and has been disabled in common/devo/power.c
        //but it helps a huge amount for the emulator
        PWR_Sleep();
    }
#endif
}
Exemple #18
0
int CyBtldr_SD_Bootload(char * file){
	char cyacd_header[10];
	char cyacd_line[589];
	unsigned char cyacd_arrayId;
	uint16 cyacd_rowAddress;
	char cyacd_rowData[288];
	uint16 cyacd_rowSize;
	unsigned char cyacd_checksum;
	unsigned long siliconId;
	unsigned char siliconRev;
	
	int err=CYRET_SUCCESS;
	int Flash_err=CYRET_SUCCESS;
	
	/*Initialize Flash Write Mechanism*/
	if(!INIT_FLASH_WRITE){
	/*If the Flash Write wasnt initialized successfully,
	fire a software reset and hope things will work out.*/
	CYBTLDR_SW_RESET;
	}
	
	/*Initialize the emFile FS*/
	FS_Init();
	
	/*Open the File for reading */
	dataFile = FS_FOpen(file, "r");
	
	/*File Opened*/
	if (NULL !=  dataFile && FS_FEof(dataFile)!=1){
		err=FS_Read(dataFile,cyacd_header,10);
		/* Read the Header line from the CYACD file.*/
        
		if (err!=0){ 
        /* Send the file pointer ahead by 4,setting it to the start of the first row */
		err=FS_FSeek( dataFile,4, FS_SEEK_CUR);
		
		/*Parse the header for SiliconID and SiliconRev*/
		err=CyBtldr_ParseHeader(10,cyacd_header,&siliconId,&siliconRev);
		
		/*Heres where you should check the SiliconID and Rev.*/
		/*
		if(CYSWAP_ENDIAN32(CYDEV_CHIP_JTAG_ID)==siliconID && CYDEV_CHIP_REV_EXPECT==siliconRev){
		}else{
		}*/
		
	}else{
		/*We have EOF or a NULL dataFile FS structure.*/
       	err = CYRET_ERR_EOF;
		return err;
	}
		
		/*Lets get to the real stuff.*/
		while(1){
		
		/*Read the First Line after the header.*/
		err=CyBtldr_ReadLine(cyacd_line);
		
		/*Check if the line was read successfully.*/
		if(err!=CYRET_SUCCESS){
			break;
		}
		
		/*Parse the line to get Row Address,Row Data,Row Size
		and the Checksum Byte*/
		err=CyBtldr_ParseRowData(589,cyacd_line,&cyacd_arrayId,&cyacd_rowAddress,&cyacd_rowData,&cyacd_rowSize,&cyacd_checksum);
		
		/*Check if the data was parsed successfully.*/
		if(err!=CYRET_SUCCESS){
			break;
		}
		
		/*Write the Row Data to flash*/
		CyWriteRowFull(cyacd_arrayId,cyacd_rowAddress,cyacd_rowData,cyacd_rowSize);
		}
		
		
		/*Close the File*/
		err=FS_FClose(dataFile);
		
		/*Fire a software reset.*/
		CYBTLDR_SW_RESET;
		
	return err;
	}
return err;
}
Exemple #19
0
/* main - function - entry point */
int main(int argc, char *argv[]) {
	lua_State *L;
	SDL_Event event;
	Uint32 lastTick;	/* Last iteration's tick value */
	Uint32 delta = 0;
	int i, n, narg;
	char *filename = NULL;

	fprintf(stdout, "%s v%s\n", PROG_NAME, VERSION);

	if (argc > 1) {
		n = 1;
		if (strcmp(argv[1], "--") != 0)
			filename = argv[1];			
	} else {
		n = argc - 1;
	}

	L = luaL_newstate();	/* initialize Lua */
	luaL_openlibs(L);	/* load Lua base libraries */

	FS_Init(L, argv, &filename);	/* initialize virtual filesystem */

	/* register Lua functions */
	lua_newtable(L);
	luaopen_main(L, NULL);
	luaopen_fileio(L, NULL);
	luaopen_font(L, NULL);
	luaopen_graphics(L, NULL);
	luaopen_sound(L, NULL);
	luaopen_mouse(L, NULL);
	luaopen_keyboard(L, NULL);
	luaopen_movie(L, NULL);
	lua_setglobal(L, NAMESPACE);
	
	/* put luaopen_oocairo in package.preload["oocairo"] */
	lua_getglobal(L, "package");
	lua_getfield(L, -1, "preload");
	lua_pushcfunction(L, luaopen_oocairo);
	lua_setfield(L, -2, "oocairo");
	
	/* put luaopen_socket_core in package.preload["socket.core"] */
	lua_pushcfunction(L, luaopen_socket_core);
	lua_setfield(L, -2, "socket.core");
	
	/* put luaopen_mime_core in package.preload["mime.core"] */
	lua_pushcfunction(L, luaopen_mime_core);
	lua_setfield(L, -2, "mime.core");
	
	lua_pop(L, 2);	
	
	/* push the error function for the protected calls later on */
	lua_pushcfunction(L, error_function);

	/* load and compile main lua file */
	if (FS_loadFile(L, filename) == FILEIO_ERROR) {
		error(L, "Error loading '%s':\n\t%s", filename, lua_tostring(L, -1));
	}

	/* push all script arguments */
	/* create arg-table for the command-line-arguments */
	/* copied from lua.c of the Lua distribution */
	narg = argc - (n+1); /* number of arguments to the script */
	luaL_checkstack(L, narg+2, "too many arguments to script");
	for (i=n+1; i<argc; i++) {
		lua_pushstring(L, argv[i]);
	}
	lua_createtable(L, narg, n+1);
	for (i=0; i<argc; i++) {
		lua_pushstring(L, argv[i]);
		lua_rawseti(L, -2, i - n);
	}
	lua_setglobal(L, "arg");

	/* run the compiled chunk */
	if ((lua_pcall(L, narg, 0, -(narg+2)) != 0) && !check_for_exit(L)) {
		error(L, "Error running '%s':\n\t%s", filename, lua_tostring(L, -1));
	}

	/* the error function stays on the stack */

	if (SDL_GetVideoSurface() == NULL)
		error(L, "Error: " PROG_NAME " was not initialized by " NAMESPACE ".init()!\n");

	/* main loop */

	/* Wait until SDL_QUIT event type (window closed) or a call to scrupp.exit() occurs */
	while ( !done ) {
		lastTick = SDL_GetTicks();

		glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

		/* maybe the 'main' table has changed
		   so get a new reference in every cycle */
		lua_getglobal(L, "main");		

		if (lua_isnil(L, -1)) {
			error(L, "Error: Table 'main' not found!\n");
		}

		/* at this point, the stack always contains 
		   the error function and the 'main' table */

		/* main.render(delta) */
		lua_getfield(L, -1, "render");
		lua_pushinteger(L, delta);
		if ((lua_pcall(L, 1, 0, -4) != 0) && !check_for_exit(L)) {
			error(L, "Error running main.render:\n\t%s\n", lua_tostring(L, -1));
		}

		SDL_GL_SwapBuffers();

		while ( SDL_PollEvent( &event ) ) {
			switch ( event.type ) {
			case SDL_QUIT:
				done = 1;
				break;

			case SDL_KEYDOWN:
				lua_getfield(L, -1, "keypressed");
				if (lua_isnil(L, -1)) {
					lua_pop(L, 1); /* pop if it's nil */
					break;
				}
				lua_pushliteral(L, "Scrupp:key_table");
				lua_rawget(L, LUA_REGISTRYINDEX);
				lua_rawgeti(L, -1, event.key.keysym.sym);
				lua_remove(L, -2); /* remove the key_table */
				if ((lua_pcall(L, 1, 0, -4) != 0) && !check_for_exit(L)) {
					error(L, "Error running main.keypressed:\n\t%s\n", lua_tostring(L, -1));
				}
				break;

			case SDL_KEYUP:
				lua_getfield(L, -1, "keyreleased");
				if (lua_isnil(L, -1)) {
					lua_pop(L, 1); /* pop if it's nil */
					break;
				}
				lua_pushliteral(L, "Scrupp:key_table");
				lua_rawget(L, LUA_REGISTRYINDEX);
				lua_rawgeti(L, -1, event.key.keysym.sym);
				lua_remove(L, -2); /* remove the key_table */				
				if ((lua_pcall(L, 1, 0, -4) != 0) && !check_for_exit(L)) {
					error(L, "Error running main.keyreleased:\n\t%s\n", lua_tostring(L, -1));
				}
				break;

			case SDL_MOUSEBUTTONDOWN:
				lua_getfield(L, -1, "mousepressed");
				if (lua_isnil(L, -1)) {
					lua_pop(L, 1); /* pop if it's nil */
					break;
				}
				lua_pushinteger(L, event.button.x);
				lua_pushinteger(L, event.button.y);
				lua_pushstring(L, buttonNames[event.button.button-1]);
				if ((lua_pcall(L, 3, 0, -6) != 0) && !check_for_exit(L)) {
					error(L, "Error running main.mousepressed:\n\t%s\n", lua_tostring(L, -1));
				}
				break;

			case SDL_MOUSEBUTTONUP:
				lua_getfield(L, -1, "mousereleased");
				if (lua_isnil(L, -1)) {
					lua_pop(L, 1); /* pop if it's nil */
					break;
				}
				lua_pushinteger(L, event.button.x);
				lua_pushinteger(L, event.button.y);
				lua_pushstring(L, buttonNames[event.button.button-1]);
				if ((lua_pcall(L, 3, 0, -6) != 0) && !check_for_exit(L)) {
					error(L, "Error running main.mousereleased:\n\t%s\n", lua_tostring(L, -1));
				}
				break;
				
			case SDL_VIDEORESIZE:
				lua_getfield(L, -1, "resized");
				if (lua_isnil(L, -1)) {
					lua_pop(L, 1); /* pop if it's nil */
					break;
				}
				lua_pushinteger(L, event.resize.w);
				lua_pushinteger(L, event.resize.h);
				if ((lua_pcall(L, 2, 0, -5) != 0) && !check_for_exit(L)) {
					error(L, "Error running main.resized:\n\t%s\n", lua_tostring(L, -1));
				}
				break;
			}
		}

		lua_pop(L, 1);	/* pop 'main' table */

		delta = SDL_GetTicks() - lastTick;

		/*
		if (delta>1) {
			fprintf(stdout, "delta: %d\n", delta);
		}
		*/

		while (delta < minimumDelta) {
			SDL_Delay(1);
			delta = SDL_GetTicks() - lastTick;
		}

	}
	lua_close(L);
	return 0;
}
Exemple #20
0
void main(){

    CyGlobalIntEnable;

    // Start up initial mote processes
    SleepTimer_Start();
    isr_SleepTimer_StartEx(sleepTimerWake_INT);
    FS_Init();  // SD Card
    modem_set_api_feed(FEED_ID, API_KEY);
    modem_start();
    ultrasonic_start();
    solinst_start();
    ADC_SAR_1_Start();
    //modem_power_off();
    
    packet_ready = 0u; 
    take_reading = 1u;
    t_sample = 2u;                                  // Initialize Sample Period to 2 minutes
    trigger_sampler = 0u;                           // Initialize automated sampler to not take a sample    
    bottle_count = 0u;                              // Initialize bottle count to zero

    NeoRTC_Start(rtcCallBackReceived);              // Start and enable the RTC.   
    NeoRTC_Set_Repeating_Minute_Alarm(t_sample);    // Set 1-minute alarm
   
    
    //  Uncomment below to set RTC
    /*
    NeoRtcTimeStruct tm = {
      .second = 00,
      .minute = 54,
      .hour = 18,
      .day = 27,
      .weekday = 2,
      .month = 5,
      .year = 2014,
    } ;
    RTC_WriteTime(tm); //sets time
    */


    for(;;){
    
        RTC_Process_Tasks();
        
        // Loop continuously and take a reading  
        // every "t_sample" minutes.
        // The variable "take_reading" is set to TRUE 
        // by rtcCallBackReceived() defined after the for() loop
        if(take_reading){ 

            // Turn on the modem to update state variables:
            //  sampling frequency; triggering the autosampler
            modem_power_on();   
           
            if (clear_packet(data_packet)) {
                packet_ready = 0u;
            }
                        
            // To communicate with the IoT platform, the node 
            // 1) listens on a given port and 2) parses an incoming string 
            // for relevant commands. Once a packet is ready to send (3), 
            // the node 4) transmits the packet.  This is achieved in as little 
            // as four lines of code by leveraging an existing TCP/IP library.
            //
            // 1) modem_get_packet()
            // 2) packet_get_uint8()
            // 3) sprintf(data_packet, ...
            // 4) modem_send_packet()
            //
            if (modem_get_packet(data_packet,"t_sample,trigger_sampler")) {
                
                // Read in any updated values
                if(packet_get_uint8(data_packet, "t_sample", &tmp)){
                    t_sample = tmp;
                }
                if(packet_get_uint8(data_packet, "trigger_sampler", &tmp)){
                    trigger_sampler = tmp;
                }
            }

            /*
            if (send_attempts > 0) {
                debug_write("New reading taken before previous packet was sent");
            }
            */

            // Trigger the autosampler to collect the sample 
            // if a sample is requested
            if (trigger_sampler){
                
                // Send in acknowledgement that packet containing
                // info re:automated sampler has been received:
                modem_send_packet("trigger_sampler, 0");
                
                trigger_sampler = 0; // Update the value locally
                
                // Trigger the autosampler as long as there are still available samples
                // If bottle_count >= MAX_BOTTLE_COUNT, skip taking a sample and avoid
                // waiting for the code to timeout
                if (bottle_count < MAX_BOTTLE_COUNT) {
                    // Turn off modem to conserve energy
                    modem_power_off();
                    
                    // Start up the autosampler processes 
                    // and power on the autosampler
                    autosampler_start();
                    autosampler_power_on();
                    

                    // Trigger the autosampler and update current bottle_count
                    autosampler_take_sample(&bottle_count);
                    
                    // Power off the autosampler
                    // and shut down the autosampler processes 
                    autosampler_power_off(); 
                    autosampler_stop();    
                }
                else {
                    debug_write("bottle_count >= MAX_BOTTLE_COUNT");
                }
            }
            
            // Construct the data packet that will be transmitted
            // by the sensor node, starting with the bottle the
            // autosampler last collected a sample in
            // (the packet is in .csv format)
            sprintf(data_packet,"%s, %u\r\n",
                "bottle", bottle_count);

            // Get Sensor Readings for:
            //  Depth, Pressure, Temperature, Conductivity
            // and update the data packet                
            if (solinst_get_reading(&solinst_reading)){
                sprintf(data_packet,"%s%s, %f\r\n", data_packet,
                    "depth_press", solinst_reading.depth);            
                    
                sprintf(data_packet,"%s%s, %f\r\n", data_packet,
                    "temp_press", solinst_reading.temp);                      
            }
            
            if (ultrasonic_get_reading(&ultrasonic_reading)){
                sprintf(data_packet,"%s%s, %f\r\n", data_packet,
                    "depth_sonic", ultrasonic_reading.depth);              
            }
            if (ReadBatteryVoltage(&vBattery)){
                sprintf(data_packet,"%s%s, %f\r\n", data_packet,
                    "V_batt", vBattery);              
            }

            // An example of writing data in JSON format
            // This was replaced with .csv format due to 
            // .csv's smaller packet size
            /*
            sprintf(data_packet, "{"
                      "\"method\":\"put\","
                      "\"resource\":\"/feeds/%d\","
                      "\"headers\":{\"X-ApiKey\":\"%s\"},"
                      "\"body\":{\"version\":\"1.0.0\",\"datastreams\":["
                            "{ \"id\" : \"depth_sonic\", \"current_value\" : \"%f\"},"
                            "{ \"id\" : \"depth_press\", \"current_value\" : \"%f\"},"
                            "{ \"id\" : \"temp_press\", \"current_value\" : \"%f\"},"
                            "{ \"id\" : \"trigger_sampler\", \"current_value\" : \"%d\"},"
                            "{ \"id\" : \"V_batt\",  \"current_value\" : \"%f\"}"
                      "]}}",
                      FEED_ID,API_KEY,
                      ultrasonic_reading.depth, solinst_reading.depth, solinst_reading.temp,0u,vBattery);
            */

            // Update flags for sending a packet and taking sensor readings
            packet_ready = 1u;
            take_reading = 0u;
            //send_attempts = 0u;
        
        // Once the flag for packet_ready has been set, 
        // send the packet and save the packet locally
        } else if(packet_ready){
            isr_SleepTimer_Stop;  //  <============= ADDRESS THIS WITH B.K.
            
            // Power on the modem in case it was turned off
            modem_power_on();
            
            // modem_state should now be IDLE or READY
            // and we can send the packet
            modem_send_packet(data_packet);
            
            // Power off the modem and conserve energy
            modem_power_off();
            
            // Backup data to SD Card
            // Use the current time to time-stamp the current reading
            NeoRtcTimeStruct tm_neo = NeoRTC_Read_Time();

            // Overwrite current data_packet with time-stamped data
            sprintf(data_packet, "\r\n%d:%d:%d %d/%d/%d -- [ID %d] u_d=%f s_d=%f s_t=%f bottle=%d v_b=%f", tm_neo.hour, tm_neo.minute,
                             tm_neo.second, tm_neo.day, tm_neo.month, tm_neo.year, moteID,
                             ultrasonic_reading.depth, solinst_reading.depth, solinst_reading.temp,bottle_count,vBattery);
            
            // Write data_packet to a *.txt file on the SD Card
            Write_To_SD_Card("data.txt","a",data_packet,strlen(data_packet));            

            // Clear the current packet in preparation for the next reading
            // when the node awakens from sleep
            if (clear_packet(data_packet)) {
                packet_ready = 0u;
            }
        
        // If either the sensor node should take a reading nor send a packet
        // go to low power mode to increase battery life    
        }else{
            // Set repeating alarm to trigger every "t_sample" minutes
            NeoRTC_Set_Repeating_Minute_Alarm(t_sample);  
            Goto_Low_Power_Mode();
        }
    CyDelay(1u);  // Quick Pause to prevent locking
    }
}
Exemple #21
0
/*
=================
Host_InitCommon
=================
*/
void Host_InitCommon( int argc, const char** argv, const char *progname, qboolean bChangeGame )
{
	char		dev_level[4];
	char		*baseDir;

	// some commands may turn engine into infinite loop,
	// e.g. xash.exe +game xash -game xash
	// so we clear all cmd_args, but leave dbg states as well
	Sys_ParseCommandLine( argc, argv );
	
	host.enabledll = !Sys_CheckParm( "-nodll" );

	host.shutdown_issued = false;
	host.crashed = false;
#ifdef DLL_LOADER
	if( host.enabledll )
		Setup_LDT_Keeper( ); // Must call before any thread creating
#endif

#if defined(XASH_SDL) && !(defined(PANDORA) || defined(RPI))
	if( SDL_Init( SDL_INIT_VIDEO |
				SDL_INIT_TIMER |
				SDL_INIT_AUDIO |
				SDL_INIT_JOYSTICK |
				SDL_INIT_EVENTS ))
	{
		Sys_Error( "SDL_Init: %s", SDL_GetError() );
	}
#endif

	if( ( baseDir = getenv( "XASH3D_BASEDIR" ) ) )
	{
		Q_strncpy( host.rootdir, baseDir, sizeof(host.rootdir) );
	}
	else
	{
		#if defined(PANDORA) || defined(RPI)
		Q_strncpy( host.rootdir, ".", sizeof( host.rootdir ) );
		#else
		#if defined(XASH_SDL)
		if( !( baseDir = SDL_GetBasePath() ) )
			Sys_Error( "couldn't determine current directory: %s", SDL_GetError() );
		Q_strncpy( host.rootdir, baseDir, sizeof( host.rootdir ) );
		#else
		if( !getcwd( host.rootdir, sizeof(host.rootdir) ) )
			host.rootdir[0] = 0;
		#endif
		#endif
	}

	if( host.rootdir[Q_strlen( host.rootdir ) - 1] == '/' )
		host.rootdir[Q_strlen( host.rootdir ) - 1] = 0;

	if( !Sys_CheckParm( "-noch" ) )
	{
		Sys_SetupCrashHandler();
	}

	host.change_game = bChangeGame;
	host.state = HOST_INIT; // initialization started
	host.developer = host.old_developer = 0;
	host.textmode = false;

	host.mempool = Mem_AllocPool( "Zone Engine" );

	if( Sys_CheckParm( "-console" )) host.developer = 1;
	if( Sys_CheckParm( "-dev" ))
	{
		if( Sys_GetParmFromCmdLine( "-dev", dev_level ))
		{
			if( Q_isdigit( dev_level ))
				host.developer = abs( Q_atoi( dev_level ));
			else host.developer++; // -dev == 1, -dev -console == 2
		}
		else host.developer++; // -dev == 1, -dev -console == 2
	}

#ifdef XASH_DEDICATED
	host.type = HOST_DEDICATED; // predict state
#else
	if( Sys_CheckParm("-dedicated") || progname[0] == '#' )
		 host.type = HOST_DEDICATED;
	else host.type = HOST_NORMAL;
#endif
	host.con_showalways = true;
	host.mouse_visible = false;

#ifdef XASH_SDL
	if( SDL_Init( SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_EVENTS ))
	{
		SDL_Init( SDL_INIT_TIMER );
		host.type = HOST_DEDICATED;
	}
#endif

	if ( SetCurrentDirectory( host.rootdir ) != 0)
		MsgDev( D_INFO, "%s is working directory now\n", host.rootdir );
	else
		Sys_Error( "Changing working directory to %s failed.\n", host.rootdir );

	// set default gamedir
	if( progname[0] == '#' ) progname++;
	Q_strncpy( SI.ModuleName, progname, sizeof( SI.ModuleName ));

	if( host.type == HOST_DEDICATED )
	{
		Sys_MergeCommandLine( );

		if( host.developer < 3 ) host.developer = 3; // otherwise we see empty console
	}
	else
	{
		// don't show console as default
		if( host.developer < D_WARN ) host.con_showalways = false;
	}

	host.old_developer = host.developer;
	if( !Sys_CheckParm( "-nowcon" ) )
		Con_CreateConsole();

	// first text message into console or log 
	MsgDev( D_NOTE, "Sys_LoadLibrary: Loading Engine Library - ok\n" );

	// startup cmds and cvars subsystem
	Cmd_Init();
	Cvar_Init();


	// share developer level across all dlls
	Q_snprintf( dev_level, sizeof( dev_level ), "%i", host.developer );
	Cvar_Get( "developer", dev_level, CVAR_INIT, "current developer level" );
	Cmd_AddCommand( "exec", Host_Exec_f, "execute a script file" );
	Cmd_AddCommand( "memlist", Host_MemStats_f, "prints memory pool information" );
	Cmd_AddCommand( "userconfigd", Host_Userconfigd_f, "execute all scripts from userconfig.d" );
	cmd_scripting = Cvar_Get( "cmd_scripting", "0", CVAR_ARCHIVE, "enable simple condition checking and variable operations" );
	
	FS_Init();
	Image_Init();
	Sound_Init();

	FS_LoadGameInfo( NULL );
	Q_strncpy( host.gamefolder, GI->gamefolder, sizeof( host.gamefolder ));

#if !(defined(PANDORA) || defined(RPI))
	if( GI->secure )
	{
		// clear all developer levels when game is protected
		Cvar_FullSet( "developer", "0", CVAR_INIT );
		host.developer = host.old_developer = 0;
		host.con_showalways = false;
	}
#endif
	HPAK_Init();

	IN_Init();
	Key_Init();
}
void MainTask(void) {
    USB_Init();
    FS_Init();
    OS_CREATETASK(&_USBTCB0, "USB Task", _USBTask, 150, _aUSBStack);
    _FSTask();
}
void MainTask(void) {
  unsigned i;
  U32 Space;
  U32 NumLoops;
  U32 NumBytes;
  U32 NumBytesAtOnce;
  FS_FILE * pFile;
  I32 t;

  FS_Init();
  _TestNo = -1;
  //
  // Check if we need to low-level format the volume
  //
  if (FS_IsLLFormatted(VOLUME_NAME) == 0) {
    FS_X_Log("Low level formatting\n");
    FS_FormatLow(VOLUME_NAME);  /* Erase & Low-level  format the flash */
  }
  //
  // Volume is always high level formatted
  // before doing any performance tests.
  //
  FS_X_Log("High level formatting\n");
#if FS_SUPPORT_FAT
  if (FS_FormatSD(VOLUME_NAME) == 0) {
#else
  if (FS_Format(VOLUME_NAME, NULL) == 0) {
#endif
    //
    // Disable that the directory entry is every time
    // updated after a write operation
    //
    FS_ConfigUpdateDirOnWrite(0);
    //
    // Fill the buffer with data
    //
    FS_MEMSET((void*)_aBuffer, 'a', sizeof(_aBuffer));
    //
    // Get some general info
    //
    Space          = FS_GetVolumeFreeSpace(VOLUME_NAME);
    Space          = MIN(Space, FILE_SIZE);
    NumBytes       = BLOCK_SIZE * NUM_BLOCKS_MEASURE;
    NumBytesAtOnce = BLOCK_SIZE;
    NumLoops       = Space / NumBytes;

    //
    // Create file of full size
    //
    _StartTest("W", NumBytes);
    pFile = FS_FOpen(FILE_NAME, "w");
    //
    // Preallocate the file, setting the file pointer to the highest position
    // and declare it as the end of the file.
    //
    FS_SetFilePos(pFile, Space, FS_FILE_BEGIN);
    FS_SetEndOfFile(pFile);
    //
    // Set file position to the beginning
    //
    FS_SetFilePos(pFile, 0, FS_FILE_BEGIN);
    //
    // Check write performance with clusters/file size preallocated
    //
    sprintf(_ac, "Writing %lu chunks of %lu Bytes: ", NumLoops, NumBytes);
    FS_X_Log(_ac);
    for (i = 0; i < NumLoops ; i++) {
      t = _WriteFile(pFile, &_aBuffer[0], NumBytesAtOnce);
      _StoreResult(t);
      FS_X_Log(".");
    }
    FS_X_Log("OK\n");
    FS_FClose(pFile);
    //
    // Check read performance
    //
    _StartTest("R", NumBytes);
    sprintf(_ac, "Reading %lu chunks of %lu Bytes: " , NumLoops, NumBytes);
    FS_X_Log(_ac);
    pFile = FS_FOpen(FILE_NAME, "r");
    for (i = 0; i < NumLoops; i++) {
      t = _ReadFile(pFile, _aBuffer, NumBytesAtOnce);
      _StoreResult(t);
      FS_X_Log(".");
    }
    FS_X_Log("OK\n\n");
    FS_FClose(pFile);
    //
    // Show results for performance list
    //
    for (i = 0; i <= (unsigned)_TestNo; i++) {
      sprintf(_ac, "%s Speed: %f kByte/s\n", _aResult[i].sName, _GetAverage(i));
      FS_X_Log(_ac);
    }
    FS_X_Log("Finished\n");
    FS_Unmount(VOLUME_NAME);
  } else {
    FS_X_Log("Volume could not be formatted!\n");
  }
  while (1) {
    ;
  }
}
Exemple #24
0
/**
 * @brief Initializes the transfer module.
 * @retval TRANSFER_OK if successful, another TRANSFER_STATUS if not.
 */
void Transfer_Init(void) {
  USB_Init();
  FS_Init(1);
}