2 * This file is part of INAV.
4 * INAV is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * INAV is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with INAV. If not, see <http://www.gnu.org/licenses/>.
20 #if defined(USE_HAL_DRIVER)
21 # define IMPL_TIM_IT_UPDATE_INTERRUPT TIM_IT_UPDATE
22 # define TIM_IT_CCx(chIdx) (TIM_IT_CC1 << (chIdx))
24 # define IMPL_TIM_IT_UPDATE_INTERRUPT TIM_IT_Update
25 # define TIM_IT_CCx(chIdx) (TIM_IT_CC1 << (chIdx))
28 #define _TIM_IRQ_HANDLER2(name, i, j) \
31 impl_timerCaptureCompareHandler(TIM ## i, timerCtx[i - 1]); \
32 impl_timerCaptureCompareHandler(TIM ## j, timerCtx[j - 1]); \
35 #define _TIM_IRQ_HANDLER(name, i) \
38 impl_timerCaptureCompareHandler(TIM ## i, timerCtx[i - 1]); \
41 uint8_t lookupTimerIndex(const TIM_TypeDef
*tim
);
42 void impl_timerInitContext(timHardwareContext_t
* timCtx
);
44 volatile timCCR_t
* impl_timerCCR(TCH_t
* tch
);
45 void impl_timerCaptureCompareHandler(TIM_TypeDef
*tim
, timHardwareContext_t
* timerCtx
);
47 void impl_timerNVICConfigure(TCH_t
* tch
, int irqPriority
);
48 void impl_timerConfigBase(TCH_t
* tch
, uint16_t period
, uint32_t hz
);
49 void impl_enableTimer(TCH_t
* tch
);
50 void impl_timerEnableIT(TCH_t
* tch
, uint32_t interrupt
);
51 void impl_timerDisableIT(TCH_t
* tch
, uint32_t interrupt
);
52 void impl_timerClearFlag(TCH_t
* tch
, uint32_t flag
);
53 void impl_timerChConfigIC(TCH_t
* tch
, bool polarityRising
, unsigned inputFilterTicks
);
54 void impl_timerChCaptureCompareEnable(TCH_t
* tch
, bool enable
);
56 void impl_timerPWMConfigChannel(TCH_t
* tch
, uint16_t value
);
57 void impl_timerPWMStart(TCH_t
* tch
);
58 bool impl_timerPWMConfigChannelDMA(TCH_t
* tch
, void * dmaBuffer
, uint8_t dmaBufferElementSize
, uint32_t dmaBufferElementCount
);
59 void impl_timerPWMPrepareDMA(TCH_t
* tch
, uint32_t dmaBufferElementCount
);
60 void impl_timerPWMStartDMA(TCH_t
* tch
);
61 void impl_timerPWMStopDMA(TCH_t
* tch
);