flipperzero-firmware/firmware/targets/f6/api-hal/api-hal-tim.c
SG a93f21dfbe
[FL-1367] fix rfid on f6 target (#500)
* RFID hal: fix gpio setup
* timers hal: crutch for HAL
* RFID hal: fix gpio setup
2021-05-28 12:38:12 +03:00

46 lines
1.3 KiB
C

#include "api-hal-tim_i.h"
#include "api-hal-irda_i.h"
#include <stm32wbxx_ll_tim.h>
#include <furi.h>
void TIM2_IRQHandler(void) {
bool consumed = false;
if(LL_TIM_IsActiveFlag_CC1(TIM2) == 1) {
if(LL_TIM_IsEnabledIT_CC1(TIM2)) {
LL_TIM_ClearFlag_CC1(TIM2);
if(READ_BIT(TIM2->CCMR1, TIM_CCMR1_CC1S)) {
// input capture
api_hal_irda_tim_isr(TimerIRQSourceCCI1);
consumed = true;
} else {
// output compare
// HAL_TIM_OC_DelayElapsedCallback(htim);
// HAL_TIM_PWM_PulseFinishedCallback(htim);
}
}
}
if(LL_TIM_IsActiveFlag_CC2(TIM2) == 1) {
if(LL_TIM_IsEnabledIT_CC2(TIM2)) {
LL_TIM_ClearFlag_CC2(TIM2);
if(READ_BIT(TIM2->CCMR1, TIM_CCMR1_CC2S)) {
// input capture
api_hal_irda_tim_isr(TimerIRQSourceCCI2);
consumed = true;
} else {
// output compare
// HAL_TIM_OC_DelayElapsedCallback(htim);
// HAL_TIM_PWM_PulseFinishedCallback(htim);
}
}
}
// TODO move all timers on LL hal
if(!consumed) {
// currently backed up with a crutch, we need more bicycles
HAL_TIM_IRQHandler(&htim2);
}
}