Lines Matching refs:cfg

316 	const struct pwm_stm32_config *cfg = dev->config;  in pwm_stm32_set_cycles()  local
331 if (!IS_TIM_32B_COUNTER_INSTANCE(cfg->timer) && in pwm_stm32_set_cycles()
338 if (LL_TIM_IsEnabledIT_CC1(cfg->timer) || LL_TIM_IsEnabledIT_CC2(cfg->timer) || in pwm_stm32_set_cycles()
339 LL_TIM_IsEnabledIT_CC3(cfg->timer) || LL_TIM_IsEnabledIT_CC4(cfg->timer)) { in pwm_stm32_set_cycles()
368 LL_TIM_CC_DisableChannel(cfg->timer, current_ll_channel); in pwm_stm32_set_cycles()
372 if (cfg->countermode == LL_TIM_COUNTERMODE_UP) { in pwm_stm32_set_cycles()
375 } else if (cfg->countermode == LL_TIM_COUNTERMODE_DOWN) { in pwm_stm32_set_cycles()
380 } else if (is_center_aligned(cfg->countermode)) { in pwm_stm32_set_cycles()
387 if (!LL_TIM_CC_IsEnabledChannel(cfg->timer, current_ll_channel)) { in pwm_stm32_set_cycles()
401 oc_init.OCState = LL_TIM_CC_IsEnabledChannel(cfg->timer, ll_channel) in pwm_stm32_set_cycles()
404 oc_init.OCPolarity = LL_TIM_OC_GetPolarity(cfg->timer, ll_channel); in pwm_stm32_set_cycles()
412 LL_TIM_CC_IsEnabledChannel(cfg->timer, negative_ll_channel) in pwm_stm32_set_cycles()
416 LL_TIM_OC_GetPolarity(cfg->timer, negative_ll_channel); in pwm_stm32_set_cycles()
427 if (IS_TIM_SLAVE_INSTANCE(cfg->timer)) { in pwm_stm32_set_cycles()
428 LL_TIM_SetSlaveMode(cfg->timer, in pwm_stm32_set_cycles()
430 LL_TIM_SetTriggerInput(cfg->timer, LL_TIM_TS_ITR0); in pwm_stm32_set_cycles()
431 LL_TIM_DisableMasterSlaveMode(cfg->timer); in pwm_stm32_set_cycles()
436 if (LL_TIM_OC_Init(cfg->timer, ll_channel, &oc_init) != SUCCESS) { in pwm_stm32_set_cycles()
441 LL_TIM_EnableARRPreload(cfg->timer); in pwm_stm32_set_cycles()
443 LL_TIM_OC_EnablePreload(cfg->timer, ll_channel); in pwm_stm32_set_cycles()
444 LL_TIM_SetAutoReload(cfg->timer, period_cycles); in pwm_stm32_set_cycles()
445 LL_TIM_GenerateEvent_UPDATE(cfg->timer); in pwm_stm32_set_cycles()
448 LL_TIM_OC_SetPolarity(cfg->timer, current_ll_channel, get_polarity(flags)); in pwm_stm32_set_cycles()
449 set_timer_compare[channel - 1u](cfg->timer, pulse_cycles); in pwm_stm32_set_cycles()
450 LL_TIM_SetAutoReload(cfg->timer, period_cycles); in pwm_stm32_set_cycles()
460 const struct pwm_stm32_config *cfg = dev->config; in init_capture_channels() local
472 if (LL_TIM_IC_Init(cfg->timer, ch2ll[channel - 1], &ic) != SUCCESS) { in init_capture_channels()
481 if (LL_TIM_IC_Init(cfg->timer, ch2ll[complimentary_channel[channel] - 1], &ic) != SUCCESS) { in init_capture_channels()
507 const struct pwm_stm32_config *cfg = dev->config; in pwm_stm32_configure_capture() local
512 if (!cfg->four_channel_capture_support) { in pwm_stm32_configure_capture()
524 if (LL_TIM_IsEnabledIT_CC1(cfg->timer) || LL_TIM_IsEnabledIT_CC2(cfg->timer) || in pwm_stm32_configure_capture()
525 LL_TIM_IsEnabledIT_CC3(cfg->timer) || LL_TIM_IsEnabledIT_CC4(cfg->timer)) { in pwm_stm32_configure_capture()
535 if (!cfg->four_channel_capture_support && !IS_TIM_SLAVE_INSTANCE(cfg->timer)) { in pwm_stm32_configure_capture()
548 LL_TIM_SetSlaveMode(cfg->timer, LL_TIM_SLAVEMODE_DISABLED); in pwm_stm32_configure_capture()
555 if (!cfg->four_channel_capture_support) { in pwm_stm32_configure_capture()
557 LL_TIM_SetTriggerInput(cfg->timer, LL_TIM_TS_TI1FP1); in pwm_stm32_configure_capture()
559 LL_TIM_SetTriggerInput(cfg->timer, LL_TIM_TS_TI2FP2); in pwm_stm32_configure_capture()
561 LL_TIM_SetSlaveMode(cfg->timer, LL_TIM_SLAVEMODE_RESET); in pwm_stm32_configure_capture()
564 LL_TIM_EnableARRPreload(cfg->timer); in pwm_stm32_configure_capture()
565 if (!IS_TIM_32B_COUNTER_INSTANCE(cfg->timer)) { in pwm_stm32_configure_capture()
566 LL_TIM_SetAutoReload(cfg->timer, 0xffffu); in pwm_stm32_configure_capture()
568 LL_TIM_SetAutoReload(cfg->timer, 0xffffffffu); in pwm_stm32_configure_capture()
570 LL_TIM_EnableUpdateEvent(cfg->timer); in pwm_stm32_configure_capture()
577 const struct pwm_stm32_config *cfg = dev->config; in pwm_stm32_enable_capture() local
581 if (!cfg->four_channel_capture_support) { in pwm_stm32_enable_capture()
593 if (LL_TIM_IsEnabledIT_CC1(cfg->timer) || LL_TIM_IsEnabledIT_CC2(cfg->timer) || in pwm_stm32_enable_capture()
594 LL_TIM_IsEnabledIT_CC3(cfg->timer) || LL_TIM_IsEnabledIT_CC4(cfg->timer)) { in pwm_stm32_enable_capture()
606 data->capture.skip_irq = cfg->four_channel_capture_support ? 0 : SKIPPED_PWM_CAPTURES; in pwm_stm32_enable_capture()
609 clear_capture_interrupt[channel - 1](cfg->timer); in pwm_stm32_enable_capture()
610 LL_TIM_ClearFlag_UPDATE(cfg->timer); in pwm_stm32_enable_capture()
612 LL_TIM_SetUpdateSource(cfg->timer, LL_TIM_UPDATESOURCE_COUNTER); in pwm_stm32_enable_capture()
614 enable_capture_interrupt[channel - 1](cfg->timer); in pwm_stm32_enable_capture()
616 LL_TIM_CC_EnableChannel(cfg->timer, ch2ll[channel - 1]); in pwm_stm32_enable_capture()
617 LL_TIM_CC_EnableChannel(cfg->timer, ch2ll[complimentary_channel[channel] - 1]); in pwm_stm32_enable_capture()
618 LL_TIM_EnableIT_UPDATE(cfg->timer); in pwm_stm32_enable_capture()
619 LL_TIM_GenerateEvent_UPDATE(cfg->timer); in pwm_stm32_enable_capture()
626 const struct pwm_stm32_config *cfg = dev->config; in pwm_stm32_disable_capture() local
628 if (!cfg->four_channel_capture_support) { in pwm_stm32_disable_capture()
640 LL_TIM_SetUpdateSource(cfg->timer, LL_TIM_UPDATESOURCE_REGULAR); in pwm_stm32_disable_capture()
642 disable_capture_interrupt[channel - 1](cfg->timer); in pwm_stm32_disable_capture()
644 LL_TIM_DisableIT_UPDATE(cfg->timer); in pwm_stm32_disable_capture()
645 LL_TIM_CC_DisableChannel(cfg->timer, ch2ll[channel - 1]); in pwm_stm32_disable_capture()
646 LL_TIM_CC_DisableChannel(cfg->timer, ch2ll[complimentary_channel[channel] - 1]); in pwm_stm32_disable_capture()
653 const struct pwm_stm32_config *cfg = dev->config; in pwm_stm32_isr() local
659 if (LL_TIM_IsActiveFlag_UPDATE(cfg->timer)) { in pwm_stm32_isr()
660 LL_TIM_ClearFlag_UPDATE(cfg->timer); in pwm_stm32_isr()
663 if (LL_TIM_IsActiveFlag_CC1(cfg->timer) in pwm_stm32_isr()
664 || LL_TIM_IsActiveFlag_CC2(cfg->timer) in pwm_stm32_isr()
665 || LL_TIM_IsActiveFlag_CC3(cfg->timer) in pwm_stm32_isr()
666 || LL_TIM_IsActiveFlag_CC4(cfg->timer)) { in pwm_stm32_isr()
667 LL_TIM_ClearFlag_CC1(cfg->timer); in pwm_stm32_isr()
668 LL_TIM_ClearFlag_CC2(cfg->timer); in pwm_stm32_isr()
669 LL_TIM_ClearFlag_CC3(cfg->timer); in pwm_stm32_isr()
670 LL_TIM_ClearFlag_CC4(cfg->timer); in pwm_stm32_isr()
677 if (LL_TIM_IsActiveFlag_UPDATE(cfg->timer)) { in pwm_stm32_isr()
678 LL_TIM_ClearFlag_UPDATE(cfg->timer); in pwm_stm32_isr()
679 if (cfg->four_channel_capture_support && in pwm_stm32_isr()
688 if (!cfg->four_channel_capture_support) { in pwm_stm32_isr()
689 if (is_capture_active[cpt->channel - 1](cfg->timer) || in pwm_stm32_isr()
690 is_capture_active[complimentary_channel[cpt->channel] - 1](cfg->timer)) { in pwm_stm32_isr()
691 clear_capture_interrupt[cpt->channel - 1](cfg->timer); in pwm_stm32_isr()
693 [complimentary_channel[cpt->channel] - 1](cfg->timer); in pwm_stm32_isr()
695 cpt->period = get_channel_capture[cpt->channel - 1](cfg->timer); in pwm_stm32_isr()
697 [complimentary_channel[cpt->channel] - 1](cfg->timer); in pwm_stm32_isr()
701 is_capture_active[cpt->channel - 1](cfg->timer)) { in pwm_stm32_isr()
712 LL_TIM_GenerateEvent_UPDATE(cfg->timer); in pwm_stm32_isr()
716 is_capture_active[cpt->channel - 1](cfg->timer)) { in pwm_stm32_isr()
722 (cfg->timer); in pwm_stm32_isr()
723 cpt->period = get_channel_capture[cpt->channel - 1](cfg->timer); in pwm_stm32_isr()
726 clear_capture_interrupt[cpt->channel - 1](cfg->timer); in pwm_stm32_isr()
757 const struct pwm_stm32_config *cfg = dev->config; in pwm_stm32_get_cycles_per_sec() local
759 *cycles = (uint64_t)(data->tim_clk / (cfg->prescaler + 1)); in pwm_stm32_get_cycles_per_sec()
777 const struct pwm_stm32_config *cfg = dev->config; in pwm_stm32_init() local
791 r = clock_control_on(clk, (clock_control_subsys_t)&cfg->pclken); in pwm_stm32_init()
797 r = get_tim_clk(&cfg->pclken, &data->tim_clk); in pwm_stm32_init()
807 r = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT); in pwm_stm32_init()
816 init.Prescaler = cfg->prescaler; in pwm_stm32_init()
817 init.CounterMode = cfg->countermode; in pwm_stm32_init()
821 if (LL_TIM_Init(cfg->timer, &init) != SUCCESS) { in pwm_stm32_init()
828 if (IS_TIM_BREAK_INSTANCE(cfg->timer)) { in pwm_stm32_init()
829 LL_TIM_EnableAllOutputs(cfg->timer); in pwm_stm32_init()
833 LL_TIM_EnableCounter(cfg->timer); in pwm_stm32_init()
836 cfg->irq_config_func(dev); in pwm_stm32_init()