Example #1
0
void __attribute__((__interrupt__,__no_auto_psv__)) _T3Interrupt(void) 
{
	// interrupt_save_extended_state ;
	
	indicate_loading_inter ;
	
	//	Executes whatever needs to be done every 25 milliseconds, using the PWM clock.
	//	This is a good place to run the A/D digital filters and compute pulse widths for servos.
	//	Also, this is used to wait a few pulses before recording input DC offsets.

#if ( NORADIO == 0 )
	twentyHertzCounter++ ;
	if ( twentyHertzCounter >= 2 )
	{
		if ( failSafePulses == 0 )
		{
			udb_flags._.radio_on = 0 ;
			LED_GREEN = LED_OFF ;
		}
		else if ( failSafePulses >= 2 )
		{
			udb_flags._.radio_on = 1 ;
			LED_GREEN = LED_ON ;
		}
		twentyHertzCounter = 0 ;
		failSafePulses = 0 ;
	}
#endif
	
	udb_servo_callback_prepare_outputs() ;
	
	OC1RS = udb_pwOut[1] ;
	OC2RS = udb_pwOut[2] ;
	OC3RS = udb_pwOut[3] ;
	OC4RS = udb_pwOut[4] ;
	OC5RS = udb_pwOut[5] ;
	OC6RS = udb_pwOut[6] ;
	OC7RS = udb_pwOut[7] ;
	OC8RS = udb_pwOut[8] ;
	
	_T3IF = 0 ;		// clear the interrupt
	
	// interrupt_restore_extended_state ;
	return ;
}
Example #2
0
void udb_run(void)
{
	uint16_t currentTime;
	uint16_t nextHeartbeatTime;
	
	
	if (strlen(SILSIM_SERIAL_RC_INPUT_DEVICE) == 0) {
		udb_pwIn[THROTTLE_INPUT_CHANNEL] = 2000;
		udb_pwTrim[THROTTLE_INPUT_CHANNEL] = 2000;
	}
	
	nextHeartbeatTime = get_current_milliseconds();
	
	while (1) {
		if (!handleUDBSockets()) {
			sleep_milliseconds(1);
		}
		
		currentTime = get_current_milliseconds();
		
		if (currentTime >= nextHeartbeatTime && !(nextHeartbeatTime <= UDB_STEP_TIME && currentTime >= UDB_WRAP_TIME-UDB_STEP_TIME)) {
			udb_callback_read_sensors();
			
			udb_flags._.radio_on = (sil_radio_on && udb_pwIn[FAILSAFE_INPUT_CHANNEL] >= FAILSAFE_INPUT_MIN && udb_pwIn[FAILSAFE_INPUT_CHANNEL] <= FAILSAFE_INPUT_MAX);
			LED_GREEN = (udb_flags._.radio_on) ? LED_ON : LED_OFF ;

			if (udb_heartbeat_counter % 20 == 0) udb_background_callback_periodic(); // Run at 2Hz
			udb_servo_callback_prepare_outputs();
			
			sil_ui_update();
			
			if (udb_heartbeat_counter % 80 == 0) writeEEPROMFileIfNeeded(); // Run at 0.5Hz
			
			udb_heartbeat_counter++;
			nextHeartbeatTime = nextHeartbeatTime + UDB_STEP_TIME;
			if (nextHeartbeatTime > UDB_WRAP_TIME) nextHeartbeatTime -= UDB_WRAP_TIME;
		}
		process_queued_events();
	}
}
Example #3
0
void __attribute__((__interrupt__,__no_auto_psv__)) _T3Interrupt(void) 
#endif
//  process TRIGGER interrupt
{
	// interrupt_save_extended_state ;
	
	indicate_loading_inter ;
	
	_TTRIGGERIF = 0 ;			// clear the interrupt
	
	iDCMframe++; // , gps_timeout++;

	if ( iDCMframe >= FRAME_ROLL )
		iDCMframe = 0;
	else ;

	if ( gps_timeout == 10000 )
			udb_background_callback_triggered(), gps_timeout = 0;
	else ;

	//	Executes whatever needs to be done every 25 milliseconds, using the PWM clock.
	//	This is a good place to run the A/D digital filters and compute pulse widths for servos.
	//	Also, this is used to wait a few pulses before recording input DC offsets.

	if ( !(iDCMframe % FRAME_40HZ_CNT) )	// has to == 0
	{
#if ( NORADIO == 0 )
#if (BOARD_TYPE == ASPG_BOARD)
// changed to run on T4 lower priority
		udb_servo_callback_prepare_outputs() ;
#endif
#endif
	}
	
	// interrupt_restore_extended_state ;
	return ;
}