VSF Documented
Data Structures | Enumerations | Functions
ledc.h File Reference
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "esp_err.h"
#include "driver/gpio.h"

Go to the source code of this file.

Data Structures

struct  ledc_timer_config_t
 LEDC timer configuration. More...
 
struct  ledc_channel_config_t
 LEDC channel configuration. More...
 

Enumerations

enum  ledc_intr_type_t {
  LEDC_INTR_DISABLE = 0 ,
  LEDC_INTR_FADE_END ,
  LEDC_INTR_MAX
}
 LEDC interrupt type (fade done). Accepted but ignored. More...
 
enum  ledc_mode_t {
  LEDC_LOW_SPEED_MODE = 0 ,
  LEDC_HIGH_SPEED_MODE ,
  LEDC_SPEED_MODE_MAX
}
 LEDC speed mode. More...
 
enum  ledc_timer_bit_t {
  LEDC_TIMER_1_BIT = 1 ,
  LEDC_TIMER_2_BIT ,
  LEDC_TIMER_3_BIT ,
  LEDC_TIMER_4_BIT ,
  LEDC_TIMER_5_BIT ,
  LEDC_TIMER_6_BIT ,
  LEDC_TIMER_7_BIT ,
  LEDC_TIMER_8_BIT ,
  LEDC_TIMER_9_BIT ,
  LEDC_TIMER_10_BIT ,
  LEDC_TIMER_11_BIT ,
  LEDC_TIMER_12_BIT ,
  LEDC_TIMER_13_BIT ,
  LEDC_TIMER_14_BIT ,
  LEDC_TIMER_15_BIT ,
  LEDC_TIMER_16_BIT ,
  LEDC_TIMER_17_BIT ,
  LEDC_TIMER_18_BIT ,
  LEDC_TIMER_19_BIT ,
  LEDC_TIMER_20_BIT ,
  LEDC_TIMER_BIT_MAX
}
 LEDC duty resolution (in bits). More...
 
enum  ledc_timer_t {
  LEDC_TIMER_0 = 0 ,
  LEDC_TIMER_1 ,
  LEDC_TIMER_2 ,
  LEDC_TIMER_3 ,
  LEDC_TIMER_MAX
}
 LEDC timer index. More...
 
enum  ledc_channel_t {
  LEDC_CHANNEL_0 = 0 ,
  LEDC_CHANNEL_1 ,
  LEDC_CHANNEL_2 ,
  LEDC_CHANNEL_3 ,
  LEDC_CHANNEL_4 ,
  LEDC_CHANNEL_5 ,
  LEDC_CHANNEL_6 ,
  LEDC_CHANNEL_7 ,
  LEDC_CHANNEL_MAX
}
 LEDC channel index. More...
 
enum  ledc_clk_cfg_t {
  LEDC_AUTO_CLK = 0 ,
  LEDC_USE_APB_CLK = 1 ,
  LEDC_USE_REF_TICK = 2 ,
  LEDC_USE_RC_FAST_CLK = 3 ,
  LEDC_USE_XTAL_CLK = 4 ,
  LEDC_USE_PLL_DIV_CLK = 5
}
 LEDC clock source. Accepted but ignored. More...
 
enum  ledc_duty_direction_t {
  LEDC_DUTY_DIR_DECREASE = 0 ,
  LEDC_DUTY_DIR_INCREASE ,
  LEDC_DUTY_DIR_MAX
}
 Fade direction. More...
 
enum  ledc_fade_mode_t {
  LEDC_FADE_NO_WAIT = 0 ,
  LEDC_FADE_WAIT_DONE ,
  LEDC_FADE_MAX
}
 Fade mode. More...
 

Functions

esp_err_t ledc_timer_config (const ledc_timer_config_t *timer_conf)
 Configure an LEDC timer (counter frequency + resolution).
 
esp_err_t ledc_channel_config (const ledc_channel_config_t *ledc_conf)
 Configure an LEDC channel (duty + timer binding).
 
esp_err_t ledc_set_duty (ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t duty)
 Set duty cycle value for a channel.
 
esp_err_t ledc_update_duty (ledc_mode_t speed_mode, ledc_channel_t channel)
 Apply the previously cached duty of a channel to hardware.
 
esp_err_t ledc_set_duty_with_hpoint (ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t duty, uint32_t hpoint)
 Set duty + hpoint and apply in one call (ESP-IDF v5.x helper).
 
uint32_t ledc_get_duty (ledc_mode_t speed_mode, ledc_channel_t channel)
 Get current duty cycle of a channel.
 
int ledc_get_hpoint (ledc_mode_t speed_mode, ledc_channel_t channel)
 Get hpoint of a channel. Always returns 0 on this shim.
 
esp_err_t ledc_set_freq (ledc_mode_t speed_mode, ledc_timer_t timer_num, uint32_t freq_hz)
 Re-program the timer frequency.
 
uint32_t ledc_get_freq (ledc_mode_t speed_mode, ledc_timer_t timer_num)
 Get the configured frequency of a timer.
 
esp_err_t ledc_stop (ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t idle_level)
 Stop a channel's output and hold it at the given idle level.
 
esp_err_t ledc_timer_pause (ledc_mode_t speed_mode, ledc_timer_t timer_num)
 Pause a timer. Accepted but reduces to a channel-level stop on this shim.
 
esp_err_t ledc_timer_resume (ledc_mode_t speed_mode, ledc_timer_t timer_num)
 Resume a timer. Accepted but reduces to an internal re-enable on this shim.
 
esp_err_t ledc_timer_rst (ledc_mode_t speed_mode, ledc_timer_t timer_num)
 Reset a timer. Accepted but no-op on this shim.
 
esp_err_t ledc_bind_channel_timer (ledc_mode_t speed_mode, ledc_channel_t channel, ledc_timer_t timer_sel)
 Bind a channel to a timer.
 
esp_err_t ledc_fade_func_install (int intr_alloc_flags)
 Install the fade service. Returns ESP_ERR_NOT_SUPPORTED.
 
void ledc_fade_func_uninstall (void)
 Uninstall the fade service. No-op on this shim.
 

Enumeration Type Documentation

◆ ledc_intr_type_t

LEDC interrupt type (fade done). Accepted but ignored.

Enumerator
LEDC_INTR_DISABLE 
LEDC_INTR_FADE_END 
LEDC_INTR_MAX 

◆ ledc_mode_t

LEDC speed mode.

Enumerator
LEDC_LOW_SPEED_MODE 
LEDC_HIGH_SPEED_MODE 
LEDC_SPEED_MODE_MAX 

◆ ledc_timer_bit_t

LEDC duty resolution (in bits).

Enumerator
LEDC_TIMER_1_BIT 
LEDC_TIMER_2_BIT 
LEDC_TIMER_3_BIT 
LEDC_TIMER_4_BIT 
LEDC_TIMER_5_BIT 
LEDC_TIMER_6_BIT 
LEDC_TIMER_7_BIT 
LEDC_TIMER_8_BIT 
LEDC_TIMER_9_BIT 
LEDC_TIMER_10_BIT 
LEDC_TIMER_11_BIT 
LEDC_TIMER_12_BIT 
LEDC_TIMER_13_BIT 
LEDC_TIMER_14_BIT 
LEDC_TIMER_15_BIT 
LEDC_TIMER_16_BIT 
LEDC_TIMER_17_BIT 
LEDC_TIMER_18_BIT 
LEDC_TIMER_19_BIT 
LEDC_TIMER_20_BIT 
LEDC_TIMER_BIT_MAX 

◆ ledc_timer_t

LEDC timer index.

Enumerator
LEDC_TIMER_0 
LEDC_TIMER_1 
LEDC_TIMER_2 
LEDC_TIMER_3 
LEDC_TIMER_MAX 

◆ ledc_channel_t

LEDC channel index.

Enumerator
LEDC_CHANNEL_0 
LEDC_CHANNEL_1 
LEDC_CHANNEL_2 
LEDC_CHANNEL_3 
LEDC_CHANNEL_4 
LEDC_CHANNEL_5 
LEDC_CHANNEL_6 
LEDC_CHANNEL_7 
LEDC_CHANNEL_MAX 

◆ ledc_clk_cfg_t

LEDC clock source. Accepted but ignored.

Enumerator
LEDC_AUTO_CLK 
LEDC_USE_APB_CLK 
LEDC_USE_REF_TICK 
LEDC_USE_RC_FAST_CLK 
LEDC_USE_XTAL_CLK 
LEDC_USE_PLL_DIV_CLK 

◆ ledc_duty_direction_t

Fade direction.

Enumerator
LEDC_DUTY_DIR_DECREASE 
LEDC_DUTY_DIR_INCREASE 
LEDC_DUTY_DIR_MAX 

◆ ledc_fade_mode_t

Fade mode.

Enumerator
LEDC_FADE_NO_WAIT 
LEDC_FADE_WAIT_DONE 
LEDC_FADE_MAX 

Function Documentation

◆ ledc_timer_config()

esp_err_t ledc_timer_config ( const ledc_timer_config_t timer_conf)
extern

Configure an LEDC timer (counter frequency + resolution).

◆ ledc_channel_config()

esp_err_t ledc_channel_config ( const ledc_channel_config_t ledc_conf)
extern

Configure an LEDC channel (duty + timer binding).

◆ ledc_set_duty()

esp_err_t ledc_set_duty ( ledc_mode_t  speed_mode,
ledc_channel_t  channel,
uint32_t  duty 
)
extern

Set duty cycle value for a channel.

Note
Call ledc_update_duty() to apply.

◆ ledc_update_duty()

esp_err_t ledc_update_duty ( ledc_mode_t  speed_mode,
ledc_channel_t  channel 
)
extern

Apply the previously cached duty of a channel to hardware.

◆ ledc_set_duty_with_hpoint()

esp_err_t ledc_set_duty_with_hpoint ( ledc_mode_t  speed_mode,
ledc_channel_t  channel,
uint32_t  duty,
uint32_t  hpoint 
)
extern

Set duty + hpoint and apply in one call (ESP-IDF v5.x helper).

◆ ledc_get_duty()

uint32_t ledc_get_duty ( ledc_mode_t  speed_mode,
ledc_channel_t  channel 
)
extern

Get current duty cycle of a channel.

Returns
duty value, or -1 on invalid argument.

◆ ledc_get_hpoint()

int ledc_get_hpoint ( ledc_mode_t  speed_mode,
ledc_channel_t  channel 
)
extern

Get hpoint of a channel. Always returns 0 on this shim.

◆ ledc_set_freq()

esp_err_t ledc_set_freq ( ledc_mode_t  speed_mode,
ledc_timer_t  timer_num,
uint32_t  freq_hz 
)
extern

Re-program the timer frequency.

◆ ledc_get_freq()

uint32_t ledc_get_freq ( ledc_mode_t  speed_mode,
ledc_timer_t  timer_num 
)
extern

Get the configured frequency of a timer.

Returns
frequency in Hz, or 0 if not configured.

◆ ledc_stop()

esp_err_t ledc_stop ( ledc_mode_t  speed_mode,
ledc_channel_t  channel,
uint32_t  idle_level 
)
extern

Stop a channel's output and hold it at the given idle level.

◆ ledc_timer_pause()

esp_err_t ledc_timer_pause ( ledc_mode_t  speed_mode,
ledc_timer_t  timer_num 
)
extern

Pause a timer. Accepted but reduces to a channel-level stop on this shim.

◆ ledc_timer_resume()

esp_err_t ledc_timer_resume ( ledc_mode_t  speed_mode,
ledc_timer_t  timer_num 
)
extern

Resume a timer. Accepted but reduces to an internal re-enable on this shim.

◆ ledc_timer_rst()

esp_err_t ledc_timer_rst ( ledc_mode_t  speed_mode,
ledc_timer_t  timer_num 
)
extern

Reset a timer. Accepted but no-op on this shim.

◆ ledc_bind_channel_timer()

esp_err_t ledc_bind_channel_timer ( ledc_mode_t  speed_mode,
ledc_channel_t  channel,
ledc_timer_t  timer_sel 
)
extern

Bind a channel to a timer.

◆ ledc_fade_func_install()

esp_err_t ledc_fade_func_install ( int  intr_alloc_flags)
extern

Install the fade service. Returns ESP_ERR_NOT_SUPPORTED.

◆ ledc_fade_func_uninstall()

void ledc_fade_func_uninstall ( void  )
extern

Uninstall the fade service. No-op on this shim.

Generated from commit: vsfteam/vsf@015f4d1