Пример #1
0
// -----------------------------------------------------------------------------
// This puts a callback into the callback ring buffer.
void SetNewDataCallback(Callback callback)
{
  if (!callback) return;
  callback_buffer_head_ = (callback_buffer_head_ + 1) % MAX_CALLBACKS;
  callback_buffer_[callback_buffer_head_] = callback;
  VIC_SWITCmd(EXTIT0_ITLine, ENABLE);
}
Пример #2
0
//------------------------------------------------------------------------------
// This function responds to the interrupt triggered when an external device
// pulls down the interrupt line (pin 5 on the FlightCtrl header). This is a
// low-priority interrupt, so some computation can be safely added here.
void FlightCtrlInterruptHandler(void)
{
  WIU_ClearITPendingBit(WIU_Line16);
  VIC_SWITCmd(EXTIT2_ITLine, DISABLE);

  PrepareFlightCtrlDataExchange();
}
Пример #3
0
//------------------------------------------------------------------------------
// This is a low-priority interrupt that is triggered by high-frequency data
// collecting interrupts such as SPI and I2C. It enables the data processing to
// be performed at a lower priority than the data collection, but at a higher
// priority that slower computations.
void NewDataInterruptHandler(void)
{
  VIC_SWITCmd(EXTIT0_ITLine, DISABLE);

  while (callback_buffer_head_ != callback_buffer_tail_)
  {
    callback_buffer_tail_ = (callback_buffer_tail_ + 1) % MAX_CALLBACKS;
    (*callback_buffer_[callback_buffer_tail_])();
  }
}
Пример #4
0
void FiftyHzInterruptHandler(void)
{
  VIC_SWITCmd(EXTIT3_ITLine, DISABLE);

  uint16_t button = GPIO_ReadBit(GPIO3, GPIO_Pin_1);
  static uint16_t button_pv = 0;

  // Start and stop magnetometer calibration.
  if (button && (button_pv == 0x7FFF)) mag_calibration_ = !mag_calibration_;

  // Reset GPS home position.
  // if (button && (button_pv == 0x7FFF)) SetGPSHome();

  button_pv = (button_pv << 1) | button;
}
Пример #5
0
//----------------------------------------------------------------------------------------------------
void TIM1_IRQHandler(void)
{
	IENABLE;

	if(TIM_GetFlagStatus(TIM1, TIM_FLAG_OC1) == SET)
	{
		TIM_ClearFlag(TIM1, TIM_FLAG_OC1); // clear irq pending bit
		TIM1->OC1R += 200;    // Timerfreq is 200kHz, generate an interrupt every 1ms
		CountMilliseconds++;
		
		// generate SW Interrupt to make a regular timing 
		// independent from the mainloop at the lowest IRQ priority
		VIC_SWITCmd(EXTIT3_ITLine, ENABLE);	
	}

	IDISABLE;
}