75 TIM_InternalClockConfig(cfg->
timer);
78 TIM_Cmd(cfg->
timer, ENABLE);
81 NVIC_Init((NVIC_InitTypeDef*)&cfg->
irq.
init);
87 if (cfg->
irq2.
init.NVIC_IRQChannel != 0)
88 NVIC_Init((NVIC_InitTypeDef*)&cfg->
irq2.
init);
122 GPIO_InitTypeDef gpio_inf;
123 gpio_inf.GPIO_Speed = GPIO_Speed_10MHz;
124 gpio_inf.GPIO_Mode = GPIO_Mode_OUT;
125 gpio_inf.GPIO_OType = GPIO_OType_PP;
126 gpio_inf.GPIO_PuPd = GPIO_PuPd_DOWN;
131 if (chan->
timer != timer) {
136 gpio_inf.GPIO_Pin = chan->
pin.
init.GPIO_Pin;
137 GPIO_Init(chan->
pin.
gpio, &gpio_inf);
148 if (!tim_dev)
goto out_fail;
156 *tim_id = (uintptr_t)tim_dev;
179 uint16_t overflow_count;
180 if (TIM_GetITStatus(timer, TIM_IT_Update) == SET) {
181 TIM_ClearITPendingBit(timer, TIM_IT_Update);
182 overflow_count = timer->ARR;
183 overflow_event =
true;
186 overflow_event =
false;
192 if (chan->
timer != timer) {
201 timer_it = TIM_IT_CC1;
204 timer_it = TIM_IT_CC2;
207 timer_it = TIM_IT_CC3;
210 timer_it = TIM_IT_CC4;
219 if (TIM_GetITStatus(chan->
timer, timer_it) == SET) {
220 TIM_ClearITPendingBit(chan->
timer, timer_it);
225 edge_count = TIM_GetCapture1(chan->
timer);
228 edge_count = TIM_GetCapture2(chan->
timer);
231 edge_count = TIM_GetCapture3(chan->
timer);
234 edge_count = TIM_GetCapture4(chan->
timer);
252 if (overflow_event && edge_event) {
264 if (edge_count < 16) {
316 static
void PIOS_TIM_1_CC_irq_handler(
void)
325 static
void PIOS_TIM_1_BRK_TIM_15_irq_handler(
void)
329 if (TIM_GetITStatus(TIM1, TIM_IT_Break)) {
331 }
else if (TIM_GetITStatus(TIM15, TIM_IT_Update | TIM_IT_CC1 | TIM_IT_CC2 | TIM_IT_CC3 | TIM_IT_CC4 | TIM_IT_COM | TIM_IT_Trigger | TIM_IT_Break)) {
339 static
void PIOS_TIM_1_UP_TIM_16_irq_handler (
void)
343 if (TIM_GetITStatus(TIM1, TIM_IT_Update)) {
345 }
else if (TIM_GetITStatus(TIM16, TIM_IT_Update | TIM_IT_CC1 | TIM_IT_CC2 | TIM_IT_CC3 | TIM_IT_CC4 | TIM_IT_COM | TIM_IT_Trigger | TIM_IT_Break)) {
352 static
void PIOS_TIM_1_TRG_COM_TIM_17_irq_handler(
void)
356 if (TIM_GetITStatus(TIM1, TIM_IT_Trigger | TIM_IT_COM)) {
358 }
else if (TIM_GetITStatus(TIM17, 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 static
void PIOS_TIM_2_irq_handler(
void)
374 static
void PIOS_TIM_3_irq_handler(
void)
382 static
void PIOS_TIM_4_irq_handler(
void)
390 static
void PIOS_TIM_6_DAC_irq_handler(
void)
399 static
void PIOS_TIM_7_irq_handler (
void)
407 static
void PIOS_TIM_8_CC_irq_handler (
void)
415 static
void PIOS_TIM_8_BRK_irq_handler (
void)
423 static
void PIOS_TIM_8_UP_irq_handler (
void)
431 static
void PIOS_TIM_8_TRG_COM_irq_handler (
void)
void TIM1_BRK_TIM15_IRQHandler(void)
void TIM3_IRQHandler(void)
const TIM_TimeBaseInitTypeDef * time_base_init
Main PiOS header to include all the compiled in PiOS options.
void TIM8_BRK_IRQHandler(void)
static uint8_t pios_tim_num_devs
#define PIOS_TIM_MAX_DEVS
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 TIM8_UP_IRQHandler(void)
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 void PIOS_TIM_generic_irq_handler(TIM_TypeDef *timer)
void TIM2_IRQHandler(void)
const struct pios_tim_callbacks * callbacks
void TIM1_UP_TIM16_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 TIM1_TRG_COM_TIM17_IRQHandler(void)
void PIOS_TIM_SetBankToGPOut(uintptr_t tim_id, TIM_TypeDef *timer)
#define PIOS_IRQ_Prologue()
void TIM8_TRG_COM_IRQHandler(void)
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)
static struct pios_tim_dev * PIOS_TIM_alloc(void)