Example #1
0
void Display::init() {
    //we need all output pins on port d
    DDRD = 0xFF;
    //port b is ICSP (programming interface) and 3 digits
    DDRB |= (1 << DIG_4) | (1 << DIG_2) | (1 << DIG_1);
    initInterrupt();

    // enable the rtc
    rtc.init();
    //rtc.writeTime(mNormalTime);
    //rtc.startClock();
}
Example #2
0
int main (void) {
	initClock(); // clock.h
	initSerial(); // serial.h
	initTimer(); // timer.h
	initADC(); // adc.h
	initInterrupt(); // interrupt.h
	initJtagShift(); // jtagshift.h
	initTdbShell(); // tdbshell.h

	tdbShellStart();

	return 0;
}
Example #3
0
/***************************************************************************
*   \brief main
*   \return void
***************************************************************************/
void main (void)
{

  int timerHandlerArray[ST_COUNT];
  
  initInterrupt();
  ST_Init();
  
  timerHandlerArray[0] = ST_Create(INTERVAL, fkt0);
  timerHandlerArray[1] = ST_Create(ONESHOT, fkt1);
  timerHandlerArray[0] = ST_Start(timerHandlerArray[0], 10000); // 10s
  
  
	while(1)
  {
    if(stateRegister.restart)
    {
      printf("Restart Taste geduerckt\n");
      stateRegister.restart = 0;
    }
    
    if(stateRegister.shoot & 0x02)
    {	
      printf("Schuss-Taste gedrueckt");
      if(!(stateRegister.shoot & 0x04))
      {
      	printf(" - Schuss abgesetzt");
      	stateRegister.shoot |= 0x04;		//WeaponDelay aktiviert
      	timerHandlerArray[1] = ST_Start(timerHandlerArray[1], 500); // 0.5s
      }
      printf("\n");
      stateRegister.shoot &= 0x05;			//Bit von Schuss-Taste l￶schen
    }
    
    if(stateRegister.move)
    {
      printf("An Drehschalter gedreht: ");
      if(stateRegister.move & SI_MOVE_LEFT)
        printf("Nach links\n");
      
      else if(stateRegister.move & SI_MOVE_RIGHT)
        printf("Nach rechts\n");
               
      else
        printf("Fehler\n");
      
      stateRegister.move = 0;
    }
 	}
}
Example #4
0
int mailbox::begin(bool mode, void (*callbackFunction)()) {
	inbox = (char*) malloc(10);
	newMessage = false; //clear new message flags.
	messageIndex = 0;
	receiveCallback = callbackFunction; //set the callback function.
	spiMode = SPI_MASTER; //DSP Shield can only be an SPI Master due to hardware limitation.
	
    SPI_Class::begin(); //initialize SPI
	SPI_Class::setClockDivider(SPI_CLOCK_DIV128);

	pinMode(SPI_RX_SEL, OUTPUT);
    pinMode(ARD_SPI_EN, OUTPUT);
    digitalWrite(SPI_RX_SEL, LOW);
    digitalWrite(ARD_SPI_EN, HIGH);
	
	//attach master select interrupt
	pinMode(MS, INPUT);
    digitalWrite(MS, HIGH);
    //Init external interrupt module
    //initInterrupt(0x0000);

    // Plugin the ISR to vector table and enbale interrupts 	
    //attachInterrupt(INTERRUPT_INT1, (INTERRUPT_IsrPtr)INT1_isr, 0);    
    //enableInterrupt(INTERRUPT_INT1);

    //Init timer interrupt module
    // Open the GPT module for GPT 0 instance 
    Timer.selectTimer(GPT0);

    // Configure GPT period 
    long period = 0x100000;
    Timer.setPeriod(period);

    // Start the Timer 
    Timer.start();
    
    // Init interrupt module
    initInterrupt(0x0000);
    Plugin the ISR to vector table and enbale interrupts 	
    attachInterrupt(INTERRUPT_TINT, (INTERRUPT_IsrPtr)INT1_isr, 0);    
    enableInterrupt(INTERRUPT_TINT);


	if(!digitalRead(MS))
		{
			receive();
		};
	return 1; //""success""
}
Example #5
0
void main()
{

	byte pattern[GHOST_WD] = {GHOST}; // Initialize the happy face pattern in memory
	ballStruct ball;


	//Initalize all the ball parameters
	ball.position.x = 5;
	ball.position.y = 5;
	ball.velocity.x = -1;
	ball.velocity.y = -1;

	ball.pattern = pattern;
	ball.width = GHOST_WD;

	ballStruct *ballPtr = &ball;


	// === Initialize system ================================================
	IFG1=0; /* clear interrupt flag1 */
	WDTCTL=WDTPW+WDTHOLD; /* stop WD */


	init();
	initNokia();
	initInterrupt();
	clearDisplay();
	drawBall(ballPtr);


	while(1)
	{

		if(!(TACTL & (BIT5|BIT4)))		// The program uses the Memory Control register to check if there is an inturrupt, an inturrupt has occured with the clock has stopped
		{
			clearDisplay();
			moveBall(ballPtr);
			drawBall(ballPtr);
			TACTL |= MC_1;				// Reset the Memory Control register to count up mode and resume (this process is fairly nice as it slows down the refresh speed)
		}
	}

}
Example #6
0
SensorHAL::SensorHAL() {
	initInterrupt();
}
Example #7
0
HAL_S::HAL_S() {
	initInterrupt();
}
Example #8
0
int main()
{
	sdcard_Init();
	initVGA();
	initAnonProfile();
	brickmap = malloc(sizeof(BrickMap));
	currentLevel->paddle = malloc(sizeof(Paddle));
	currentLevel->buff=malloc(sizeof(Buff));
	int i,j;
	for(i=0;i<maxBalls;i++)
		currentLevel->ball[i] = malloc(sizeof(Ball));

	for(i=0;i<maxRows;i++)
		for(j=0;j<bricksPerRow;j++)
			currentLevel->bricks[i][j]=malloc(sizeof(Brick));


	level=1;


	//pre load the root menu
	getMenu(&currentMenu,rootMenu, 1);

	//allocate memory for level farm


	//set the game to playing
	prevState=currentState=Playing;


	//look up the level from level farm and load it into currentLevel
	levelLookUp(brickmap,level);
	initLevel(*brickmap);
	drawStart(currentLevel);   //this is optional here
	swapBuffers();
	drawStart(currentLevel);

	runCountDown();              //count down from three
	initInterrupt();            //start the game (we dont need to right off the bat (probably shouldnt)

	int counter=0;   //so were not doing direct IO reads on EVERY iteration (we could timer this buttttt no)
	while(1)
	{
		//input to state machine
		counter++;
		if(counter>22000)
		{
			counter=0;
			if(getMenuPB())
			{
				while(getMenuPB() != 0);
				if(currentState == Playing)
					changeState(MenuShow);
			}
		}
		//flicker changes
		if(prevState != currentState)
		{
			if(currentState == Playing)
			{
				clearScreen();
				drawStart(currentLevel);   //this is optional here
				swapBuffers();
				drawStart(currentLevel);
				runCountDown();
				initInterrupt();
			}else
			{
				stopInterrupt();
				getMenu(&currentMenu,rootMenu, 1);
				clearScreen();
				drawStart(currentLevel);   //this is optional here
				swapBuffers();
				drawStart(currentLevel);
				drawMenu(currentMenu);
			}
			prevState = currentState;
		}
		//state machine
		if(currentState == MenuShow)
		{
			menuLoop();
		}else //while were playing we will have to check for other things (all balls gone etc.)
		{
			if(currentLevel->brickCount<=0)
			{
				printf("starting new level \n");
				stopInterrupt();
				level++;
				levelLookUp(brickmap,level);
				initLevel(*brickmap);
				prevState= currentState - 1;
				currentState = Playing;
				printf("finished starting new level \n");
			}
		}
	}
	return 0;
}
Example #9
0
static void initConsole( void )
{
    if( info.console_output ) {
        initInterrupt();
    }
}
Example #10
0
//*****************************************************************************
//	Function:	interruptsInit
//	Arguments: 	None
//	Action: 	Interrupts Initialised
//	Returns: 	None
//*****************************************************************************
void interruptsInit( void )
{
  initInterrupt();
}