Example #1
0
/*
 * Sets up a context for a future thread or co-routine.
 */
void ContextInit( struct CONTEXT * context, char * Pointer, COUNT Size, STACK_INIT_ROUTINE Foo, void * Arg)
{
#ifdef DEBUG
        int cur;
#endif

#ifdef DEBUG
        //Set up the stack boundry.
        CounterInit(&context->TimesRun);
        CounterInit(&context->TimesSwitched);
        context->LastRanTime = 0;
        context->LastSelectedTime = 0;

#endif

        //initialize stack
        if( Size != 0 )
        {
#ifdef DEBUG
                context->High = (char *) (Pointer + Size);
                context->Low = Pointer;
                //Write pattern over stack so we can expose
                //variable initialization errors.
                for(cur=0; cur<Size; cur++)
                        Pointer[cur] = 0xaa;
#endif
                //Populate regular stack
                context->Main = Foo;
                context->MainArg = Arg;
                HalCreateStackFrame( &context->MachineState, Pointer, Size, ContextBootstrap, context);
        }
        else
        {
#ifdef DEBUG
                context->High = (char*) -1;
                context->Low = 0;
#endif
                //Populate stack for idle thread (machine's start thread).
                HalGetInitialStackFrame( &context->MachineState );

        }
}
Example #2
0
void initController()
{

	pauseSeq = 1;								//In case of the Timing Engine is in "Firing" on powering up, this setting can prevent it from actually firing

	KPLED_All_Bright();							//Turn on all keypad LEDs (Bright)

	DisInit();									//Initialize Display
	DisCurPos(1,1);
	DisWrStr("Initializing...");				//Show message "Initializing..."

	UartInit();									//Initialize Nios UART


	remoteEn = 1;								//Disable Remote Control (make sure Nios core has the right of the UART)
	DisClear();
	DisCurPos(1,1);
	DisWrStr("Remote Mode!");
	KPLED_All_Off();
	while(remoteEn){
    }
	DisClear();
	DisCurPos(1,1);
	DisWrStr("Initializing...");
	Stop();										//Send a Stop instruction to the Timing Engine. Make sure it's not firing on initial state.


	clrTimer = 1; 								//Reset Password&Heater Timer
	clrTimer = 0;

	clrPreionFault = 1;							//Clear Preion Fault Handler
	clrPreionFault = 0;

	clrInterlock=1;								//Clear Interlock Handler
	clrInterlock=0;

	//InterlockIn=1;
	//InterlockIn=0;

	//InterockSplitted=1;
	//InterockSplitted=0;

	loadData();									//Load Data From EEPROM to Main RAM
	delay(5000);								//There is no signal that indicates if the loading is done so use delay() to wait.

	KPLED_All_Dim();							//Turn on all keypad LEDs (Dim)
	delay(5000);

	reloadRegisters();							//Reload all Timing Engine registers with current data in Main RAM. (Load data from EEPROM does not refresh those registers)


	refreshErrFlags();							//Data Error Check

	CounterInit();								//Load Counters data to FPGA Counter module (from FRAM)

	PowerFailure_Init();						//Power Failure Handler Initialization (enable interrupt and register ISR)

	pauseSeq = 0;								//Clear Pause

	KPLED_All_Off();							//Turn off all keypad LEDs

	printf("Done!\n");							//Send massage through JTAG, for debugging.
}