void EXTI4_IRQHandler(void) //EXTernal interrupt routine PB4-Yaw { static unsigned short rc4a = 0, rc4b = 0; //if (EXTI_GetITStatus(EXTI_Line4) != RESET) if (EXTI->PR & (1 << 4)) { DEBUG_PutChar('4'); if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_4) == 1) { rc4a = TIM3->CNT; } if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_4) == 0) { rc4b = TIM3->CNT; } unsigned short diff = rc4b - rc4a; if ((diff > 1000) && (diff < 2000)) { rc4 = (int)diff - 1000; } else { //rc4 = 0; } // EXTI3 interrupt pending? //EXTI_ClearITPendingBit(EXTI_Line4); // clear pending interrupt EXTI->PR |= (1 << 4); // clear pending interrupt } }
void EXTI3_IRQHandler(void) //EXTernal interrupt routine PB3-Pitch { static unsigned short rc3a, rc3b; if (EXTI->PR & (1 << 3)) { DEBUG_PutChar('3'); // EXTI3 interrupt pending? EXTI->PR |= (1 << 3); // clear pending interrupt if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 1) { rc3a = TIM3->CNT; } if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) == 0) { rc3b = TIM3->CNT; } unsigned short diff = rc3b - rc3a; if ((diff > 1000) && (diff < 2000)) { rc3 = (int)diff - 1000; } else { rc3 = 0; } } }
void EXTI4_IRQHandler(void) //EXTernal interrupt routine PB4-Yaw { static unsigned short rc4a, rc4b; if (EXTI->PR & (1 << 4)) { DEBUG_PutChar('4'); // EXTI3 interrupt pending? EXTI->PR |= (1 << 4); // clear pending interrupt if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_4) == 1) { rc4a = TIM3->CNT; } if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_4) == 0) { rc4b = TIM3->CNT; } unsigned short diff = rc4b - rc4a; if ((diff > 1000) && (diff < 2000)) { rc4 = (int)diff - 1000; } else { rc4 = 0; } } }
void EXTI2_IRQHandler(void) //EXTernal interrupt routine PC2-Pitch { static unsigned short rc2a, rc2b; if (EXTI->PR & (1 << 2)) { DEBUG_PutChar('2'); // EXTI2 interrupt pending? EXTI->PR |= (1 << 2); // clear pending interrupt if (GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_2) == 1) { rc2a = TIM3->CNT; } if (GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_2) == 0) { rc2b = TIM3->CNT; } unsigned short diff = rc2b - rc2a; if ((diff > 1000) && (diff < 2000)) { rc2 = (int)diff - 1000; } else { rc2 = 0; } } }
/************************************************************************** Function: void DEBUG_PutString(char* data); Summary: Prints a string to the debug stream. Description: Prints a string to the debug stream. Precondition: None Parameters: None Return Values: None Remarks: None **************************************************************************/ void DEBUG_PutString(char* data) { UINT16 i; i = 0; do { DEBUG_PutChar(data[i]); } while(data[i++] != 0); }
void EXTI2_IRQHandler(void) //EXTernal interrupt routine PC2-Pitch { static unsigned short rc2a = 0, rc2b = 0; //if (EXTI_GetITStatus(EXTI_Line2) != RESET) if (EXTI->PR & (1 << 2)) { DEBUG_PutChar('2'); if (GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_2) == 1) { rc2a = TIM3->CNT; } if (GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_2) == 0) { rc2b = TIM3->CNT; } unsigned short diff = rc2b - rc2a; if ((diff > 1000) && (diff < 2000)) { rc2 = (int)diff - 1000; } else { //rc2 = 0; } // EXTI2 interrupt pending? //EXTI_ClearITPendingBit(EXTI_Line2); // clear pending interrupt EXTI->PR |= (1 << 2); // clear pending interrupt } }