api-hal-tim.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include "api-hal-tim_i.h"
  2. #include "api-hal-irda_i.h"
  3. #include <stm32wbxx_ll_tim.h>
  4. #include <furi.h>
  5. void TIM2_IRQHandler(void) {
  6. bool consumed = false;
  7. if(LL_TIM_IsActiveFlag_CC1(TIM2) == 1) {
  8. if(LL_TIM_IsEnabledIT_CC1(TIM2)) {
  9. LL_TIM_ClearFlag_CC1(TIM2);
  10. if(READ_BIT(TIM2->CCMR1, TIM_CCMR1_CC1S)) {
  11. // input capture
  12. api_hal_irda_tim_isr(TimerIRQSourceCCI1);
  13. consumed = true;
  14. } else {
  15. // output compare
  16. // HAL_TIM_OC_DelayElapsedCallback(htim);
  17. // HAL_TIM_PWM_PulseFinishedCallback(htim);
  18. }
  19. }
  20. }
  21. if(LL_TIM_IsActiveFlag_CC2(TIM2) == 1) {
  22. if(LL_TIM_IsEnabledIT_CC2(TIM2)) {
  23. LL_TIM_ClearFlag_CC2(TIM2);
  24. if(READ_BIT(TIM2->CCMR1, TIM_CCMR1_CC2S)) {
  25. // input capture
  26. api_hal_irda_tim_isr(TimerIRQSourceCCI2);
  27. consumed = true;
  28. } else {
  29. // output compare
  30. // HAL_TIM_OC_DelayElapsedCallback(htim);
  31. // HAL_TIM_PWM_PulseFinishedCallback(htim);
  32. }
  33. }
  34. }
  35. // TODO move all timers on LL hal
  36. if(!consumed) {
  37. // currently backed up with a crutch, we need more bicycles
  38. HAL_TIM_IRQHandler(&htim2);
  39. }
  40. }