Lines Matching refs:timer_num
55 #define MCPWM_TIMER_ID_CHECK(mcpwm_num, timer_num) … argument
58 …ESP_RETURN_ON_FALSE((timer_num) < SOC_MCPWM_TIMERS_PER_GROUP, ESP_ERR_INVALID_ARG, TAG, MCPWM_TIME…
61 #define MCPWM_TIMER_CHECK(mcpwm_num, timer_num) … argument
63 …MCPWM_TIMER_ID_CHECK(mcpwm_num, timer_num); …
67 #define MCPWM_GEN_CHECK(mcpwm_num, timer_num, gen) \ argument
69 MCPWM_TIMER_CHECK(mcpwm_num, timer_num); \
185 esp_err_t mcpwm_start(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num) in mcpwm_start() argument
187 MCPWM_TIMER_CHECK(mcpwm_num, timer_num); in mcpwm_start()
190 …mcpwm_ll_timer_set_execute_command(context[mcpwm_num].hal.dev, timer_num, MCPWM_TIMER_START_NO_STO… in mcpwm_start()
195 esp_err_t mcpwm_stop(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num) in mcpwm_stop() argument
197 MCPWM_TIMER_CHECK(mcpwm_num, timer_num); in mcpwm_stop()
200 …mcpwm_ll_timer_set_execute_command(context[mcpwm_num].hal.dev, timer_num, MCPWM_TIMER_STOP_AT_ZERO… in mcpwm_stop()
216 esp_err_t mcpwm_timer_set_resolution(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, unsigned long… in mcpwm_timer_set_resolution() argument
217 MCPWM_TIMER_CHECK(mcpwm_num, timer_num); in mcpwm_timer_set_resolution()
222 context[mcpwm_num].timer_pre_scale[timer_num] = pre_scale_temp; in mcpwm_timer_set_resolution()
224 …mcpwm_ll_timer_set_clock_prescale(hal->dev, timer_num, context[mcpwm_num].timer_pre_scale[timer_nu… in mcpwm_timer_set_resolution()
229 esp_err_t mcpwm_set_frequency(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, uint32_t frequency) in mcpwm_set_frequency() argument
232 const int op = timer_num; in mcpwm_set_frequency()
233 MCPWM_TIMER_CHECK(mcpwm_num, timer_num); in mcpwm_set_frequency()
238 mcpwm_ll_timer_update_period_at_once(hal->dev, timer_num); in mcpwm_set_frequency()
239 uint32_t previous_peak = mcpwm_ll_timer_get_peak(hal->dev, timer_num, false); in mcpwm_set_frequency()
242 …C_MCPWM_BASE_CLK_HZ / real_group_prescale / mcpwm_ll_timer_get_clock_prescale(hal->dev, timer_num); in mcpwm_set_frequency()
244 mcpwm_ll_timer_set_peak(hal->dev, timer_num, new_peak, false); in mcpwm_set_frequency()
260 esp_err_t mcpwm_set_duty(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, mcpwm_generator_t gen, fl… in mcpwm_set_duty() argument
263 const int op = timer_num; in mcpwm_set_duty()
266 MCPWM_GEN_CHECK(mcpwm_num, timer_num, gen); in mcpwm_set_duty()
270 uint32_t set_duty = mcpwm_ll_timer_get_peak(hal->dev, timer_num, false) * duty / 100; in mcpwm_set_duty()
277 esp_err_t mcpwm_set_duty_in_us(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, mcpwm_generator_t g… in mcpwm_set_duty_in_us() argument
280 const int op = timer_num; in mcpwm_set_duty_in_us()
283 MCPWM_GEN_CHECK(mcpwm_num, timer_num, gen); in mcpwm_set_duty_in_us()
289 …C_MCPWM_BASE_CLK_HZ / real_group_prescale / mcpwm_ll_timer_get_clock_prescale(hal->dev, timer_num); in mcpwm_set_duty_in_us()
296 esp_err_t mcpwm_set_duty_type(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, mcpwm_generator_t ge… in mcpwm_set_duty_type() argument
300 const int op = timer_num; in mcpwm_set_duty_type()
301 MCPWM_GEN_CHECK(mcpwm_num, timer_num, gen); in mcpwm_set_duty_type()
307 switch (mcpwm_ll_timer_get_count_mode(hal->dev, timer_num)) { in mcpwm_set_duty_type()
378 esp_err_t mcpwm_init(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, const mcpwm_config_t *mcpwm_c… in mcpwm_init() argument
380 const int op = timer_num; in mcpwm_init()
393 …mcpwm_ll_timer_set_clock_prescale(hal->dev, timer_num, context[mcpwm_num].timer_pre_scale[timer_nu… in mcpwm_init()
394 mcpwm_ll_timer_set_count_mode(hal->dev, timer_num, mcpwm_conf->counter_mode); in mcpwm_init()
395 mcpwm_ll_timer_update_period_at_once(hal->dev, timer_num); in mcpwm_init()
398 …C_MCPWM_BASE_CLK_HZ / real_group_prescale / mcpwm_ll_timer_get_clock_prescale(hal->dev, timer_num); in mcpwm_init()
399 mcpwm_ll_timer_set_peak(hal->dev, timer_num, real_timer_clk_hz / mcpwm_conf->frequency, false); in mcpwm_init()
400 …mcpwm_ll_operator_select_timer(hal->dev, timer_num, timer_num); //the driver currently always use … in mcpwm_init()
403 mcpwm_set_duty(mcpwm_num, timer_num, 0, mcpwm_conf->cmpr_a); in mcpwm_init()
404 mcpwm_set_duty(mcpwm_num, timer_num, 1, mcpwm_conf->cmpr_b); in mcpwm_init()
405 mcpwm_set_duty_type(mcpwm_num, timer_num, 0, mcpwm_conf->duty_mode); in mcpwm_init()
406 mcpwm_set_duty_type(mcpwm_num, timer_num, 1, mcpwm_conf->duty_mode); in mcpwm_init()
407 mcpwm_start(mcpwm_num, timer_num); in mcpwm_init()
412 uint32_t mcpwm_get_frequency(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num) in mcpwm_get_frequency() argument
414 MCPWM_TIMER_CHECK(mcpwm_num, timer_num); in mcpwm_get_frequency()
419 …C_MCPWM_BASE_CLK_HZ / real_group_prescale / mcpwm_ll_timer_get_clock_prescale(hal->dev, timer_num); in mcpwm_get_frequency()
420 uint32_t peak = mcpwm_ll_timer_get_peak(hal->dev, timer_num, false); in mcpwm_get_frequency()
426 float mcpwm_get_duty(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, mcpwm_generator_t gen) in mcpwm_get_duty() argument
429 const int op = timer_num; in mcpwm_get_duty()
430 MCPWM_GEN_CHECK(mcpwm_num, timer_num, gen); in mcpwm_get_duty()
433 …perator_get_compare_value(hal->dev, op, gen) / mcpwm_ll_timer_get_peak(hal->dev, timer_num, false); in mcpwm_get_duty()
438 uint32_t mcpwm_get_duty_in_us(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, mcpwm_operator_t gen… in mcpwm_get_duty_in_us() argument
440 const int op = timer_num; in mcpwm_get_duty_in_us()
441 MCPWM_GEN_CHECK(mcpwm_num, timer_num, gen); in mcpwm_get_duty_in_us()
446 …C_MCPWM_BASE_CLK_HZ / real_group_prescale / mcpwm_ll_timer_get_clock_prescale(hal->dev, timer_num); in mcpwm_get_duty_in_us()
452 esp_err_t mcpwm_set_signal_high(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, mcpwm_generator_t … in mcpwm_set_signal_high() argument
455 return mcpwm_set_duty_type(mcpwm_num, timer_num, gen, MCPWM_HAL_GENERATOR_MODE_FORCE_HIGH); in mcpwm_set_signal_high()
458 esp_err_t mcpwm_set_signal_low(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, mcpwm_generator_t g… in mcpwm_set_signal_low() argument
461 return mcpwm_set_duty_type(mcpwm_num, timer_num, gen, MCPWM_HAL_GENERATOR_MODE_FORCE_LOW); in mcpwm_set_signal_low()
464 esp_err_t mcpwm_carrier_enable(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num) in mcpwm_carrier_enable() argument
467 const int op = timer_num; in mcpwm_carrier_enable()
468 MCPWM_TIMER_CHECK(mcpwm_num, timer_num); in mcpwm_carrier_enable()
476 esp_err_t mcpwm_carrier_disable(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num) in mcpwm_carrier_disable() argument
479 const int op = timer_num; in mcpwm_carrier_disable()
480 MCPWM_TIMER_CHECK(mcpwm_num, timer_num); in mcpwm_carrier_disable()
488 esp_err_t mcpwm_carrier_set_period(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, uint8_t carrier… in mcpwm_carrier_set_period() argument
491 const int op = timer_num; in mcpwm_carrier_set_period()
492 MCPWM_TIMER_CHECK(mcpwm_num, timer_num); in mcpwm_carrier_set_period()
500 esp_err_t mcpwm_carrier_set_duty_cycle(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, uint8_t car… in mcpwm_carrier_set_duty_cycle() argument
503 const int op = timer_num; in mcpwm_carrier_set_duty_cycle()
504 MCPWM_TIMER_CHECK(mcpwm_num, timer_num); in mcpwm_carrier_set_duty_cycle()
512 esp_err_t mcpwm_carrier_oneshot_mode_enable(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, uint8_… in mcpwm_carrier_oneshot_mode_enable() argument
515 const int op = timer_num; in mcpwm_carrier_oneshot_mode_enable()
516 MCPWM_TIMER_CHECK(mcpwm_num, timer_num); in mcpwm_carrier_oneshot_mode_enable()
524 esp_err_t mcpwm_carrier_oneshot_mode_disable(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num) in mcpwm_carrier_oneshot_mode_disable() argument
526 return mcpwm_carrier_oneshot_mode_enable(mcpwm_num, timer_num, 0); in mcpwm_carrier_oneshot_mode_disable()
529 esp_err_t mcpwm_carrier_output_invert(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, in mcpwm_carrier_output_invert() argument
533 const int op = timer_num; in mcpwm_carrier_output_invert()
534 MCPWM_TIMER_CHECK(mcpwm_num, timer_num); in mcpwm_carrier_output_invert()
542 esp_err_t mcpwm_carrier_init(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, const mcpwm_carrier_c… in mcpwm_carrier_init() argument
545 const int op = timer_num; in mcpwm_carrier_init()
546 MCPWM_TIMER_CHECK(mcpwm_num, timer_num); in mcpwm_carrier_init()
549 mcpwm_carrier_enable(mcpwm_num, timer_num); in mcpwm_carrier_init()
550 mcpwm_carrier_set_period(mcpwm_num, timer_num, carrier_conf->carrier_period); in mcpwm_carrier_init()
551 mcpwm_carrier_set_duty_cycle(mcpwm_num, timer_num, carrier_conf->carrier_duty); in mcpwm_carrier_init()
553 mcpwm_carrier_oneshot_mode_enable(mcpwm_num, timer_num, carrier_conf->pulse_width_in_os); in mcpwm_carrier_init()
555 mcpwm_carrier_oneshot_mode_disable(mcpwm_num, timer_num); in mcpwm_carrier_init()
557 mcpwm_carrier_output_invert(mcpwm_num, timer_num, carrier_conf->carrier_ivt_mode); in mcpwm_carrier_init()
566 esp_err_t mcpwm_deadtime_enable(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, mcpwm_deadtime_typ… in mcpwm_deadtime_enable() argument
570 const int op = timer_num; in mcpwm_deadtime_enable()
571 MCPWM_TIMER_CHECK(mcpwm_num, timer_num); in mcpwm_deadtime_enable()
653 esp_err_t mcpwm_deadtime_disable(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num) in mcpwm_deadtime_disable() argument
656 const int op = timer_num; in mcpwm_deadtime_disable()
657 MCPWM_TIMER_CHECK(mcpwm_num, timer_num); in mcpwm_deadtime_disable()
700 esp_err_t mcpwm_fault_set_cyc_mode(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, mcpwm_fault_sig… in mcpwm_fault_set_cyc_mode() argument
704 const int op = timer_num; in mcpwm_fault_set_cyc_mode()
720 esp_err_t mcpwm_fault_set_oneshot_mode(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, mcpwm_fault… in mcpwm_fault_set_oneshot_mode() argument
724 const int op = timer_num; in mcpwm_fault_set_oneshot_mode()
900 esp_err_t mcpwm_sync_enable(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, mcpwm_sync_signal_t sy… in mcpwm_sync_enable() argument
903 MCPWM_TIMER_CHECK(mcpwm_num, timer_num); in mcpwm_sync_enable()
909 uint32_t set_phase = mcpwm_ll_timer_get_peak(hal->dev, timer_num, false) * phase_val / 1000; in mcpwm_sync_enable()
910 mcpwm_ll_timer_set_sync_phase_value(hal->dev, timer_num, set_phase); in mcpwm_sync_enable()
912 mcpwm_ll_timer_set_soft_synchro(hal->dev, timer_num); in mcpwm_sync_enable()
914 mcpwm_ll_timer_set_timer_synchro(hal->dev, timer_num, sync_sig - MCPWM_SELECT_TIMER0_SYNC); in mcpwm_sync_enable()
916 mcpwm_ll_timer_set_gpio_synchro(hal->dev, timer_num, sync_sig - MCPWM_SELECT_GPIO_SYNC0); in mcpwm_sync_enable()
918 mcpwm_ll_timer_enable_sync_input(hal->dev, timer_num, true); in mcpwm_sync_enable()
923 esp_err_t mcpwm_sync_configure(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, const mcpwm_sync_co… in mcpwm_sync_configure() argument
925 MCPWM_TIMER_CHECK(mcpwm_num, timer_num); in mcpwm_sync_configure()
930 mcpwm_ll_timer_set_sync_phase_direction(hal->dev, timer_num, sync_conf->count_direction); in mcpwm_sync_configure()
933 set_phase = mcpwm_ll_timer_get_peak(hal->dev, timer_num, false) * sync_conf->timer_val / 1000; in mcpwm_sync_configure()
934 mcpwm_ll_timer_set_sync_phase_value(hal->dev, timer_num, set_phase); in mcpwm_sync_configure()
936 mcpwm_ll_timer_set_soft_synchro(hal->dev, timer_num); in mcpwm_sync_configure()
938 …mcpwm_ll_timer_set_timer_synchro(hal->dev, timer_num, sync_conf->sync_sig - MCPWM_SELECT_TIMER0_SY… in mcpwm_sync_configure()
940 …mcpwm_ll_timer_set_gpio_synchro(hal->dev, timer_num, sync_conf->sync_sig - MCPWM_SELECT_GPIO_SYNC0… in mcpwm_sync_configure()
942 mcpwm_ll_timer_enable_sync_input(hal->dev, timer_num, true); in mcpwm_sync_configure()
947 esp_err_t mcpwm_sync_disable(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num) in mcpwm_sync_disable() argument
949 MCPWM_TIMER_CHECK(mcpwm_num, timer_num); in mcpwm_sync_disable()
953 mcpwm_ll_timer_enable_sync_input(hal->dev, timer_num, false); in mcpwm_sync_disable()
958 esp_err_t mcpwm_timer_trigger_soft_sync(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num) in mcpwm_timer_trigger_soft_sync() argument
960 MCPWM_TIMER_CHECK(mcpwm_num, timer_num); in mcpwm_timer_trigger_soft_sync()
964 mcpwm_ll_timer_trigger_soft_sync(hal->dev, timer_num); in mcpwm_timer_trigger_soft_sync()
982 esp_err_t mcpwm_set_timer_sync_output(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, mcpwm_timer_… in mcpwm_set_timer_sync_output() argument
984 MCPWM_TIMER_CHECK(mcpwm_num, timer_num); in mcpwm_set_timer_sync_output()
990 mcpwm_ll_timer_sync_out_penetrate(hal->dev, timer_num); in mcpwm_set_timer_sync_output()
993 mcpwm_ll_timer_sync_out_on_timer_event(hal->dev, timer_num, MCPWM_TIMER_EVENT_ZERO); in mcpwm_set_timer_sync_output()
996 mcpwm_ll_timer_sync_out_on_timer_event(hal->dev, timer_num, MCPWM_TIMER_EVENT_PEAK); in mcpwm_set_timer_sync_output()
1000 mcpwm_ll_timer_disable_sync_out(hal->dev, timer_num); in mcpwm_set_timer_sync_output()