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_25MHz;
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;
180 uint16_t overflow_count;
181 if (TIM_GetITStatus(timer, TIM_IT_Update) == SET) {
182 TIM_ClearITPendingBit(timer, TIM_IT_Update);
183 overflow_count = timer->ARR;
184 overflow_event =
true;
187 overflow_event =
false;
193 if (chan->
timer != timer) {
202 timer_it = TIM_IT_CC1;
205 timer_it = TIM_IT_CC2;
208 timer_it = TIM_IT_CC3;
211 timer_it = TIM_IT_CC4;
220 if (TIM_GetITStatus(chan->
timer, timer_it) == SET) {
221 TIM_ClearITPendingBit(chan->
timer, timer_it);
226 edge_count = TIM_GetCapture1(chan->
timer);
229 edge_count = TIM_GetCapture2(chan->
timer);
232 edge_count = TIM_GetCapture3(chan->
timer);
235 edge_count = TIM_GetCapture4(chan->
timer);
253 if (overflow_event && edge_event) {
265 if (edge_count < 16) {
317 static
void PIOS_TIM_1_CC_irq_handler (
void)
326 static
void PIOS_TIM_1_BRK_TIM_9_irq_handler (
void)
330 if (TIM_GetITStatus(TIM1, TIM_IT_Break)) {
332 }
else if (TIM_GetITStatus(TIM9, TIM_IT_Update | TIM_IT_CC1 | TIM_IT_CC2 | TIM_IT_CC3 | TIM_IT_CC4 | TIM_IT_COM | TIM_IT_Trigger | TIM_IT_Break)) {
340 static
void PIOS_TIM_1_UP_TIM_10_irq_handler (
void)
344 if (TIM_GetITStatus(TIM1, TIM_IT_Update)) {
346 }
else if (TIM_GetITStatus(TIM10, TIM_IT_Update | TIM_IT_CC1 | TIM_IT_CC2 | TIM_IT_CC3 | TIM_IT_CC4 | TIM_IT_COM | TIM_IT_Trigger | TIM_IT_Break)) {
353 static
void PIOS_TIM_1_TRG_COM_TIM_11_irq_handler (
void)
357 if (TIM_GetITStatus(TIM1, TIM_IT_Trigger | TIM_IT_COM)) {
359 }
else if (TIM_GetITStatus(TIM11, TIM_IT_Update | TIM_IT_CC1 | TIM_IT_CC2 | TIM_IT_CC3 | TIM_IT_CC4 | TIM_IT_COM | TIM_IT_Trigger | TIM_IT_Break)) {
366 #ifndef PIOS_OMIT_TIM2IRQ
368 static
void PIOS_TIM_2_irq_handler (
void)
377 static
void PIOS_TIM_3_irq_handler (
void)
384 #if !defined(PIOS_VIDEO_TIM4_COUNTER)
386 static
void PIOS_TIM_4_irq_handler (
void)
395 static
void PIOS_TIM_5_irq_handler (
void)
403 static
void PIOS_TIM_6_DAC_irq_handler (
void)
412 static
void PIOS_TIM_7_irq_handler (
void)
420 static
void PIOS_TIM_8_CC_irq_handler (
void)
429 static
void PIOS_TIM_8_BRK_TIM_12_irq_handler (
void)
433 if (TIM_GetITStatus(TIM8, TIM_IT_Break)) {
435 }
else if (TIM_GetITStatus(TIM12, TIM_IT_Update | TIM_IT_CC1 | TIM_IT_CC2 | TIM_IT_CC3 | TIM_IT_CC4 | TIM_IT_COM | TIM_IT_Trigger | TIM_IT_Break)) {
443 static
void PIOS_TIM_8_UP_TIM_13_irq_handler (
void)
447 if (TIM_GetITStatus(TIM8, TIM_IT_Update)) {
449 }
else if (TIM_GetITStatus(TIM13, TIM_IT_Update | TIM_IT_CC1 | TIM_IT_CC2 | TIM_IT_CC3 | TIM_IT_CC4 | TIM_IT_COM | TIM_IT_Trigger | TIM_IT_Break)) {
457 static
void PIOS_TIM_8_TRG_COM_TIM_14_irq_handler (
void)
461 if (TIM_GetITStatus(TIM8, TIM_IT_Trigger | TIM_IT_COM)) {
463 }
else if (TIM_GetITStatus(TIM14, TIM_IT_Update | TIM_IT_CC1 | TIM_IT_CC2 | TIM_IT_CC3 | TIM_IT_CC4 | TIM_IT_COM | TIM_IT_Trigger | TIM_IT_Break)) {
void TIM8_TRG_COM_TIM14_IRQHandler(void)
void TIM3_IRQHandler(void)
const TIM_TimeBaseInitTypeDef * time_base_init
static void PIOS_TIM_generic_irq_handler(TIM_TypeDef *timer)
void TIM1_UP_TIM10_IRQHandler(void)
void TIM1_TRG_COM_TIM11_IRQHandler(void)
Main PiOS header to include all the compiled in PiOS options.
void TIM5_IRQHandler(void)
static uint8_t pios_tim_num_devs
#define PIOS_TIM_MAX_DEVS
void TIM8_BRK_TIM12_IRQHandler(void)
void PIOS_TIM_InitTimerPin(uintptr_t tim_id, int idx)
void TIM6_DAC_IRQHandler(void)
#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 TIM7_IRQHandler(void)
enum pios_tim_dev_magic magic
static struct flyingpicmd_cfg_fa cfg
void TIM4_IRQHandler(void)
static struct pios_tim_dev pios_tim_devs[PIOS_TIM_MAX_DEVS]
int32_t PIOS_TIM_InitClock(const struct pios_tim_clock_cfg *cfg)
static struct pios_tim_dev * PIOS_TIM_alloc(void)
void TIM2_IRQHandler(void)
const struct pios_tim_callbacks * callbacks
void TIM8_UP_TIM13_IRQHandler(void)
void TIM8_CC_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 TIM1_BRK_TIM9_IRQHandler(void)
#define PIOS_IRQ_Prologue()
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)