Exemplo n.º 1
0
//-------------------------------------------------------
//Function: 
//Desc	: 
//Input	:
//Output: 
//Return: 
//Others: 
//Author: 
//Date	: 2011/03/01
//-------------------------------------------------------
void system_inital(void)
{
	WaitUs(5);
	
	mcu_clk_inital();
	mcu_io_inital();
	memset(&system, 0, sizeof(SYS_STRUCT));	
	DISABLE_INTERRUPT;	
	InitSysTimer();
	WaitUs(600);
//	system_read_MTPrecord();
	BK2433_RF_Initial();

	AudioInit();
	if(bUSBMode)
		usb_ini();
	
	ENABLE_INTERRUPT;

	#ifdef DEBUG
	UartOpen();
	#endif

	PowerUp_RF();
}
Exemplo n.º 2
0
int main(void)
{
	IOInit();
	
	#if defined UART_AVAILABLE
		UARTInit(UART_BAUDRATE);			// 9600
	#endif									// UART_AVAILABLE
	
	InitSysTimer(SYS_TICK_PERIOD);			// 500 ms
	CreateTask(Task_1, 0, IDLE);
	CreateTask(Task_2, 4, SUSPEND);
	CreateTask(Task_3, 2, SUSPEND);
	while(1)								// general cycle
	{
		Run();
	}
}
Exemplo n.º 3
0
void MainServer()
{
	InitInterfaceLocks(); 
	
	InitInterface(); /* starts a thread with the window */

   WrapInit();
	
	InitMemory(); /* memory needs channels in general, but need to start before config,
	so just be careful. */
	
	InitConfig();
	LoadConfig();		/* must be nearly first since channels use it */
	
	InitDebug();
	
	InitChannelBuffer();
	
	OpenDefaultChannels();
	
	lprintf("Starting %s\n",BlakServLongVersionString());
	
	InitClass();
	InitMessage();
	InitObject();
	InitList();
	InitTimer();
	InitSession();
	InitResource();
	InitRoomData();
	InitString();
	InitUser();
	InitAccount();
	InitNameID();
	InitDLlist();   
	InitSysTimer();
	InitMotd();
	InitLoadBof();
	InitTime();
	InitGameLock();
	InitBkodInterpret();
	InitBufferPool();
	InitTable();
	AddBuiltInDLlist();
	
	LoadMotd();
	LoadBof();
	LoadRsc();
	LoadKodbase();
	
	LoadAdminConstants();
	
	PauseTimers();
	
	if (LoadAll() == True)
	{
	/* this loaded_game_msg tells it to disconnect all blakod info about sessions,
		* that were logged on when we saved */
		
		SendTopLevelBlakodMessage(GetSystemObjectID(),LOADED_GAME_MSG,0,NULL);
		DoneLoadAccounts();
	}
	
	/* these must be after LoadAll and ClearList */
	InitCommCli(); 
	InitParseClient(); 
	InitProfiling();
	InitAsyncConnections();
	
	UpdateSecurityRedbook();
	
	UnpauseTimers();

	

	ServiceTimers();
	/* returns if server termiated */
	
	MainExitServer();
   WrapShutdown();
}
void main(void)
{

    IFR = 0x0000;
    IER = 0x0000;

    DisableWatchdog();
    InitSysParameters();                        // Initialization of system parameters
    InitSysTimer();                             // Initialization of system timer

#if (USE_TEST1_PIN)
    TEST_1_INI();
    TEST_1_OFF();
#endif
#if (USE_TEST2_PIN)
    TEST_2_INI();
    TEST_2_OFF();
#endif

    InitWatchdog();                             // Initialization of watchdog
    InitXWatchdog();                            // Initialization of extern watchdog

    InitIndicators();
//    InitSwitches();
    InitKeyboard();

    SetTimer(T_LED, T_LED_D);                   // Set Timers
    SetTimer(T_SEC, T_SEC_D);
    SetTimer(T_SWT, T_SWT_D);

    PieCtrlRegs.PIEACK.all = 0xFFFF;            // Enables PIE to drive a pulse into the CPU
    EINT;                                       // Enable Interrupts at the CPU level

    //--- Enable interrupts
    //SetDBGIER(IER);                             // Configure the DBGIER for realtime debug
    //asm(" CLRC INTM, DBGM");                    // Enable global interrupts and realtime debug

    TimeDev.second = 0;
    TimeDev.minute = 0;
    TimeDev.hour = 0;
    TimeDev.date = 0;

    EnableWatchdog();
//--------------------------------------------------------------------------------------------------
    for(;;)                                     // Main loop
    {
        ServiceWatchdog();                     // Reset Watchdog
//--------------------------------------------------------------------------------------------------
//----------------------------------------------// Time intervals
        if(CheckTimer(T_SEC))
        {
            SetTimer(T_SEC, T_SEC_D);
            if (++TimeDev.second > 59)
            {
                TimeDev.second = 0;
                if (++TimeDev.minute > 59)
                {
                    TimeDev.minute = 0;
                    if (++TimeDev.hour > 23)
                    {
                        TimeDev.hour = 0;
                        TimeDev.date++;
                    }
                }
            }
        }
//--------------------------------------------------------------------------------------------------
//----------------------------------------------// Indication
        if(CheckTimer(T_LED))
        {
            Debug[0]++;
            SetTimer(T_LED, T_LED_D);
//----------------------------------------------// Signaling the state of the system

//            ControlLedWork(TOGGLE);            // LED indicates normal work of the system
            //ControlIndicatorPower(TOGGLE);     // Indication of connection to the power line
//----------------------------------------------// Signaling presence of errors
            /*if (FlagDev.bit.ERR)
            {
                ControlLedError(TOGGLE);
                //ControlIndicatorError(TOGGLE);
            }
            else
            {
                ControlLedError(OFF);
                //ControlIndicatorError(OFF);
            }*/

#if (USE_INDICATOR1)
//----------------------------------------------// Indication of the device working
                                                // in the converter mode
            /*if (FlagDev.bit.WORK)
            {
                ControlIndicatorWork(ON);
            }
            else
            {
                ControlIndicatorWork(OFF);
            }*/
#endif

#if (USE_INDICATOR2)
//----------------------------------------------// Indication of the presence of communication
                                                // with the control device
            /*if (!ErrorDev.bit.CTR)
            {
                ControlIndicatorLink(ON);
            }
            else
            {
                ControlIndicatorLink(OFF);
            }*/
#endif
        }

        if(CheckTimer(T_SWT))
        {

#if (USE_SWT1)
            if (CheckButtonStop() && !CheckButtonStart())
            {
                FlagDev.bit.STOP = 1;
            }
#endif

#if (USE_SWT2)
            if (CheckButtonStart() && !CheckButtonStop())
            {
                FlagDev.bit.PUSK = 1;
            }
#endif

#if (USE_SWT3)
            if (CheckButtonReset())
            {
                FlagDev.bit.RESET = 1;
            }
#endif

#if (USE_ONB_BUT1)
            if (CheckButtonOnboard1())
            {
                ControlLedOnboard3(ON);
            }
            else
            {
                ControlLedOnboard3(OFF);
            }
#endif

#if (USE_KBRD)
            CheckKeyboard();
            if(KeyboardStat.bit.BUT1)
            {
                ControlLedWork(ON);
                Debug[1] = 1;
            }
            else
            {
                ControlLedWork(OFF);
                Debug[1] = 0;
            }
            if(KeyboardStat.bit.BUT2)
            {
                ControlLedError(ON);
                Debug[2] = 1;
            }
            else
            {
                ControlLedError(OFF);
                Debug[2] = 0;
            }
            if(KeyboardStat.bit.BUT4)
            {
                ControlLedOnboard3(ON);
                Debug[3] = 1;
            }
            else
            {
                ControlLedOnboard3(OFF);
                Debug[3] = 0;
            }
            if(KeyboardStat.bit.BUT5)
            {
                ControlLedOnboard4(ON);
                Debug[4] = 1;
            }
            else
            {
                ControlLedOnboard4(OFF);
                Debug[4] = 0;
            }
#endif
        }
//--------------------------------------------------------------------------------------------------
    }
}