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