InputCapture.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "InputCapture.h"
  2. #include "bikespeed.h"
  3. #include "Cadence.h"
  4. #include "Api_rt.h"
  5. #include "FSM_1st.h"
  6. void IC_CountMaxISR(void)
  7. {
  8. if(switch_flg.SysCoef_Flag == TRUE)
  9. {
  10. UWORD uwIntSource = 1;
  11. cadence_voCadenceCal(uwIntSource);
  12. bikespeed_voBikeSpeedCal(uwIntSource);
  13. }
  14. }
  15. void IC_CadenceISR(void)
  16. {
  17. if(switch_flg.SysCoef_Flag == TRUE)
  18. {
  19. UWORD uwIntSource = 2;
  20. cadence_voCadenceCal(uwIntSource);
  21. /* Select rising or falling edge trigger */
  22. if(iGpio_Read(HW_GPIO_CADENCE_PIN) != 0)
  23. {
  24. /* reset the CH2P and CH2NP bits */
  25. // TIMER_CHCTL2(TIMER1) &= ~(uint32_t)(TIMER_CHCTL2_CH2P|TIMER_CHCTL2_CH2NP);
  26. // TIMER_CHCTL2(TIMER1) |= (uint32_t)((uint32_t)(TIMER_IC_POLARITY_FALLING) << 8U);
  27. iCap_SetEdgeType(0, CAP_CH(2), ApiCap_FallingEdge);
  28. }
  29. else
  30. {
  31. /* reset the CH2P and CH2NP bits */
  32. // TIMER_CHCTL2(TIMER1) &= ~(uint32_t)(TIMER_CHCTL2_CH2P|TIMER_CHCTL2_CH2NP);
  33. // TIMER_CHCTL2(TIMER1) |= (uint32_t)((uint32_t)(TIMER_IC_POLARITY_RISING) << 8U);
  34. iCap_SetEdgeType(0, CAP_CH(2), ApiCap_RisingEdge);
  35. }
  36. }
  37. }
  38. void IC_BikeSpdISR(void)
  39. {
  40. if(switch_flg.SysCoef_Flag == TRUE)
  41. {
  42. UWORD uwIntSource = 3;
  43. bikespeed_voBikeSpeedCal(uwIntSource);
  44. }
  45. }