76 TIM_InternalClockConfig(cfg->
timer);
79 TIM_Cmd(cfg->
timer, ENABLE);
82 NVIC_Init((NVIC_InitTypeDef*)&cfg->
irq.
init);
88 if (cfg->
irq2.
init.NVIC_IRQChannel != 0)
89 NVIC_Init((NVIC_InitTypeDef*)&cfg->
irq2.
init);
123 GPIO_InitTypeDef gpio_inf;
124 gpio_inf.GPIO_Speed = GPIO_Speed_10MHz;
125 gpio_inf.GPIO_Mode = GPIO_Mode_OUT;
126 gpio_inf.GPIO_OType = GPIO_OType_PP;
127 gpio_inf.GPIO_PuPd = GPIO_PuPd_DOWN;
132 if (chan->
timer != timer) {
137 gpio_inf.GPIO_Pin = chan->
pin.
init.GPIO_Pin;
138 GPIO_Init(chan->
pin.
gpio, &gpio_inf);
149 if (!tim_dev)
goto out_fail;
157 *tim_id = (uintptr_t)tim_dev;
171 uint16_t overflow_count;
172 if (TIM_GetITStatus(timer, TIM_IT_Update) == SET) {
173 TIM_ClearITPendingBit(timer, TIM_IT_Update);
174 overflow_count = timer->ARR;
175 overflow_event =
true;
178 overflow_event =
false;
194 if (chan->
timer != timer) {
203 timer_it = TIM_IT_CC1;
206 timer_it = TIM_IT_CC2;
209 timer_it = TIM_IT_CC3;
212 timer_it = TIM_IT_CC4;
221 if (TIM_GetITStatus(chan->
timer, timer_it) == SET) {
222 TIM_ClearITPendingBit(chan->
timer, timer_it);
227 edge_count = TIM_GetCapture1(chan->
timer);
230 edge_count = TIM_GetCapture2(chan->
timer);
233 edge_count = TIM_GetCapture3(chan->
timer);
236 edge_count = TIM_GetCapture4(chan->
timer);
254 if (overflow_event && edge_event) {
266 if (edge_count < 16) {
319 static
void PIOS_TIM_1_irq_handler (
void)
328 static
void PIOS_TIM_2_irq_handler (
void)
336 static
void PIOS_TIM_3_irq_handler (
void)
344 static
void PIOS_TIM_6_irq_handler (
void)
352 static
void PIOS_TIM_14_irq_handler (
void)
360 static
void PIOS_TIM_15_irq_handler (
void)
368 static
void PIOS_TIM_16_irq_handler (
void)
376 static
void PIOS_TIM_17_irq_handler (
void)
void TIM3_IRQHandler(void)
const TIM_TimeBaseInitTypeDef * time_base_init
Main PiOS header to include all the compiled in PiOS options.
static uint8_t pios_tim_num_devs
#define PIOS_TIM_MAX_DEVS
void PIOS_TIM_InitTimerPin(uintptr_t tim_id, int idx)
#define PIOS_DEBUG_Assert(test)
#define PIOS_IRQ_Epilogue()
void(* overflow)(uintptr_t tim_id, uintptr_t context, uint8_t chan_idx, uint16_t count)
const struct pios_tim_channel * channels
void PIOS_TIM_InitAllTimerPins(uintptr_t tim_id)
void TIM15_IRQHandler(void)
static struct pios_tim_dev * PIOS_TIM_alloc(void)
enum pios_tim_dev_magic magic
static struct flyingpicmd_cfg_fa cfg
static struct pios_tim_dev pios_tim_devs[PIOS_TIM_MAX_DEVS]
int32_t PIOS_TIM_InitClock(const struct pios_tim_clock_cfg *cfg)
void TIM16_IRQHandler(void)
void TIM2_IRQHandler(void)
const struct pios_tim_callbacks * callbacks
void TIM1_BRK_UP_TRG_COM_IRQHandler(void)
int32_t PIOS_TIM_InitChannels(uintptr_t *tim_id, const struct pios_tim_channel *channels, uint8_t num_channels, const struct pios_tim_callbacks *callbacks, uintptr_t context)
void PIOS_TIM_SetBankToGPOut(uintptr_t tim_id, TIM_TypeDef *timer)
void TIM17_IRQHandler(void)
void TIM6_IRQHandler(void)
#define PIOS_IRQ_Prologue()
void TIM14_IRQHandler(void)
static void PIOS_TIM_generic_irq_handler(TIM_TypeDef *timer)
void TIM1_CC_IRQHandler(void)
void(* edge)(uintptr_t tim_id, uintptr_t context, uint8_t chan_idx, uint16_t count)
#define PIOS_Assert(test)