mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 14:25:20 +03:00
36 lines
1.1 KiB
C
36 lines
1.1 KiB
C
#pragma once
|
|
|
|
#ifdef CHEBUZZF3
|
|
#define USABLE_TIMER_CHANNEL_COUNT 18
|
|
#else
|
|
#define USABLE_TIMER_CHANNEL_COUNT 14
|
|
#endif
|
|
|
|
#ifdef STM32F303xC
|
|
typedef uint32_t captureCompare_t;
|
|
#endif
|
|
#ifdef STM32F10X_MD
|
|
typedef uint16_t captureCompare_t;
|
|
#endif
|
|
|
|
typedef void timerCCCallbackPtr(uint8_t port, captureCompare_t capture);
|
|
|
|
typedef struct {
|
|
TIM_TypeDef *tim;
|
|
GPIO_TypeDef *gpio;
|
|
uint32_t pin;
|
|
uint8_t channel;
|
|
uint8_t irq;
|
|
uint8_t outputEnable;
|
|
GPIO_Mode gpioInputMode;
|
|
} timerHardware_t;
|
|
|
|
extern const timerHardware_t timerHardware[];
|
|
|
|
void configTimeBase(TIM_TypeDef *tim, uint16_t period, uint8_t mhz);
|
|
void timerConfigure(const timerHardware_t *timerHardwarePtr, uint16_t period, uint8_t mhz);
|
|
void timerNVICConfigure(uint8_t irq);
|
|
|
|
void configureTimerInputCaptureCompareChannel(TIM_TypeDef *tim, const uint8_t channel);
|
|
void configureTimerCaptureCompareInterrupt(const timerHardware_t *timerHardwarePtr, uint8_t reference, timerCCCallbackPtr *callback);
|
|
void configureTimerChannelCallback(TIM_TypeDef *tim, uint8_t channel, uint8_t reference, timerCCCallbackPtr *callback);
|