InputCapture.c 1.4 KB

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