void TimerIsr(void)
{
  if (TAIV) // clear interrupt
  {
    tick += 1;
    WatchdogPet();
  }
}
Exemplo n.º 2
0
/**
* Check that each subsystem within the application is still running and then
* if everything is OK, reset the watchdog countdown timer to prevent a
* restart. If one of the subsystems has failed, allow the watchdog to timeout
* and force a restart.
* @note This function is called once per second from the system timer.
*/
void WatchdogValidate(void)
{
	bool systemStalled = false;

	/* Main loop still running? */
	if (mainLoopWatchdog == 0)
	{
		// TODO re-enable this once wdt is debugged
		// sendDBGLine("TASK_MAIN watchdog task timeout");
		// systemStalled = true;
	}
	else
	{
		mainLoopWatchdog--;
	}

	if (!systemStalled)
	{
		WatchdogPet();
	}
}
Exemplo n.º 3
0
void ManufactureTestButtonPress(void)
{
	startTimeout(&biosUnused, BIOS_UNUSED_MS);
	while(1)
	{
		uint8_t red = LED_OFF;
		uint8_t green = LED_OFF;
		uint8_t blue = LED_OFF;		
		
		WatchdogPet();
		
		if (buttonActivated(B_START) & buttonActivated(B_SELECT))
		{
			delay_ms(500);
			reset_do_soft_reset();
		}
		
		if(checkTimeout(&biosUnused))
		{
			cancelTimeout(&biosUnused);
			setLEDValue(0, 0, 0);
			powerOff(global_header.powerOffSoftware);
		}

		if( buttonActivated(B_UP) ||
			buttonActivated(B_DOWN) ||
			buttonActivated(B_LEFT) ||
			buttonActivated(B_RIGHT) ||
			buttonActivated(B_A) ||
			buttonActivated(B_B) ||
			buttonActivated(B_X) ||
			buttonActivated(B_Y) ||
			buttonActivated(B_START) ||
			buttonActivated(B_SELECT) ||
			buttonActivated(B_LB) ||
			buttonActivated(B_RB) ||
			buttonActivated(B_LT) ||
			buttonActivated(B_RT) ||
			buttonActivated(B_JL) ||
			buttonActivated(B_JR)
		)
		{
			green = LED_DIM;
		}
		
		for(uint8_t idx = 0 ; idx<NUM_JOYSTICKS; idx++) 
		{
			uint16_xy raw;
			raw.x = sampleAnalogChannel(joysticks[idx].adc_channel_x);
			raw.y = sampleAnalogChannel(joysticks[idx].adc_channel_y);
			
			int16_xy out;
			SimpleJoystickAdj( center[idx], &deadzone, &raw, &out );
			
			//Write raw and adjusted X,Y values to USB serial port
			PrintXY(raw.x,raw.y);
			sendUSBString("->", false);
			PrintXY(out.x,out.y);
			sendUSBLine("");
			
			if( out.y<0 )
			{
				//up is yellow
				red = LED_DIM;
				green = LED_DIM;
			}
			else if( out.y>0 )
			{
				//down is blue
				blue = LED_DIM;
			}
			else if( out.x>0 )
			{
				//right is Red
				red = LED_DIM;
			}
			else if( out.x<0 )
			{
				//left is green
				green = LED_DIM;
			}
		}
		
		setLEDValue(red, green, blue);
				
	} // end while(1)
}