Blackbox device type 'file' (SITL) considered working when file handler is available
[inav.git] / src / main / drivers / timer_impl.h
blob4d0a87f9aa5b5d2270ecb23b751fc2f816d4a78d
1 /*
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/>.
18 #pragma once
20 #if defined(AT32F43x)
21 #define IMPL_TIM_IT_UPDATE_INTERRUPT TMR_OVF_INT
22 #define TIM_IT_CCx(chIdx) (TMR_C1_INT << (chIdx))
23 // 0x2 0x4 0x8 0x10 0\1\2\3
25 #define _TIM_IRQ_HANDLER2(name, i, j) \
26 void name(void) \
27 { \
28 impl_timerCaptureCompareHandler(TMR ## i, timerCtx[i - 1]); \
29 impl_timerCaptureCompareHandler(TMR ## j, timerCtx[j - 1]); \
30 } struct dummy
32 #define _TIM_IRQ_HANDLER(name, i) \
33 void name(void) \
34 { \
35 impl_timerCaptureCompareHandler(TMR ## i, timerCtx[i - 1]); \
36 } struct dummy
38 uint8_t lookupTimerIndex(const tmr_type *tim);
39 void impl_timerCaptureCompareHandler(tmr_type *tim, timHardwareContext_t * timerCtx);
41 #else // end at32
43 #if defined(USE_HAL_DRIVER)
44 # define IMPL_TIM_IT_UPDATE_INTERRUPT TIM_IT_UPDATE
45 # define TIM_IT_CCx(chIdx) (TIM_IT_CC1 << (chIdx))
46 #else
47 #define IMPL_TIM_IT_UPDATE_INTERRUPT TIM_IT_Update
48 #define TIM_IT_CCx(chIdx) (TIM_IT_CC1 << (chIdx))
49 #endif
51 #define _TIM_IRQ_HANDLER2(name, i, j) \
52 void name(void) \
53 { \
54 impl_timerCaptureCompareHandler(TIM ## i, timerCtx[i - 1]); \
55 impl_timerCaptureCompareHandler(TIM ## j, timerCtx[j - 1]); \
56 } struct dummy
58 #define _TIM_IRQ_HANDLER(name, i) \
59 void name(void) \
60 { \
61 impl_timerCaptureCompareHandler(TIM ## i, timerCtx[i - 1]); \
62 } struct dummy
64 uint8_t lookupTimerIndex(const TIM_TypeDef *tim);
65 void impl_timerCaptureCompareHandler(TIM_TypeDef *tim, timHardwareContext_t * timerCtx);
67 #endif //end of else (stm32)
69 void impl_timerInitContext(timHardwareContext_t * timCtx);
71 volatile timCCR_t * impl_timerCCR(TCH_t * tch);
72 void impl_timerNVICConfigure(TCH_t * tch, int irqPriority);
73 void impl_timerConfigBase(TCH_t * tch, uint16_t period, uint32_t hz);
74 void impl_enableTimer(TCH_t * tch);
75 void impl_timerEnableIT(TCH_t * tch, uint32_t interrupt);
76 void impl_timerDisableIT(TCH_t * tch, uint32_t interrupt);
77 void impl_timerClearFlag(TCH_t * tch, uint32_t flag);
78 void impl_timerChConfigIC(TCH_t * tch, bool polarityRising, unsigned inputFilterTicks);
79 void impl_timerChCaptureCompareEnable(TCH_t * tch, bool enable);
81 void impl_timerPWMConfigChannel(TCH_t * tch, uint16_t value);
82 void impl_timerPWMStart(TCH_t * tch);
83 bool impl_timerPWMConfigChannelDMA(TCH_t * tch, void * dmaBuffer, uint8_t dmaBufferElementSize, uint32_t dmaBufferElementCount);
84 void impl_timerPWMPrepareDMA(TCH_t * tch, uint32_t dmaBufferElementCount);
85 void impl_timerPWMStartDMA(TCH_t * tch);
86 void impl_timerPWMStopDMA(TCH_t * tch);
88 #ifdef USE_DSHOT_DMAR
89 bool impl_timerPWMConfigDMABurst(burstDmaTimer_t *burstDmaTimer, TCH_t * tch, void * dmaBuffer, uint8_t dmaBufferElementSize, uint32_t dmaBufferElementCount);
90 void impl_pwmBurstDMAStart(burstDmaTimer_t * burstDmaTimer, uint32_t BurstLength);
91 #endif