Example #1
0
File: v9v1.c Project: hollylxj/Lab4
void RefreshSensorData(void * Parameters)
{
vSemaphoreCreateBinary(xSemaphore);
  /* Go to infinite loop when Memory Manage exception occurs */
  while (1){
refreshSensorData();
xSemaphoreGive(xSemaphore);
vTaskDelay(100);
  }
}
Example #2
0
/*
 * TIM2_IRQHandler - The interrupt handler for timer 2. There are 4 possible
 *					 interrupt channels. 
 *
 * Inputs: None
 * Outputs: None
 * Modifies: Possibly extern global var pid_set_flag
 */
void TIM2_IRQHandler(void) {

	// Channel 1 is the interrupt for the detectEmegency() function
	if (TIM_GetITStatus(TIM2, TIM_IT_CC1) != RESET) {

		// Clear the IRQ
		TIM_ClearITPendingBit(TIM2, TIM_IT_CC1);
		detectEmergency();

		// Interrupt needs to trigger again in 10ms
		capture  = TIM_GetCapture1(TIM2);
		TIM_SetCompare1(TIM2, capture + DELAY_10MS);

	// Channel 2 is the interrupt for refreshSensorData()
	} else if (TIM_GetITStatus(TIM2, TIM_IT_CC2) != RESET) {

		// Clear the IRQ
		TIM_ClearITPendingBit(TIM2, TIM_IT_CC2);
		refreshSensorData();

		// Interrupt needs to trigger again in 100ms
		capture  = TIM_GetCapture2(TIM2);
		TIM_SetCompare2(TIM2, capture + DELAY_100MS);


	// Channel 3 is the interupt for calculateOrientation()
	} else if (TIM_GetITStatus(TIM2, TIM_IT_CC3) != RESET) {

		// Clear the IRQ
		TIM_ClearITPendingBit(TIM2, TIM_IT_CC2);
		calculateOrientation();
		// This function refreshes once a second, so no need to reset the
		// compare register

	// Channel 4 is the interrupt for updatePid()
	} else {

		// Clear the IRQ
		TIM_ClearITPendingBit(TIM2, TIM_IT_CC4);

		// This function returns new motor PIDs, which means the main
		// program needs to do additional processing after the interrupt
		updatePid(&motor_speeds);
		pid_set_flag = True;
		// This function refreshes once a second, so no need to reset the
		// compare register
	}

}