diff --git a/components/driver/include/driver/ledc.h b/components/driver/include/driver/ledc.h index 2dffce8c9..3e3d3740d 100644 --- a/components/driver/include/driver/ledc.h +++ b/components/driver/include/driver/ledc.h @@ -34,24 +34,29 @@ typedef enum { //LEDC_LOW_SPEED_MODE, /*LEDC low speed speed_mode */ LEDC_SPEED_MODE_MAX, } ledc_mode_t; + typedef enum { LEDC_INTR_DISABLE = 0, /*Disable LEDC interrupt */ LEDC_INTR_FADE_END, /*Enable LEDC interrupt */ } ledc_intr_type_t; + typedef enum { LEDC_DUTY_DIR_DECREASE = 0, /*LEDC duty decrease direction */ LEDC_DUTY_DIR_INCREASE = 1, /*LEDC duty increase direction */ } ledc_duty_direction_t; + typedef enum { LEDC_REF_TICK = 0, /*LEDC timer clock divided from reference tick(1Mhz) */ LEDC_APB_CLK, /*LEDC timer clock divided from APB clock(80Mhz)*/ } ledc_clk_src_t; + typedef enum { LEDC_TIMER0 = 0, /*LEDC source timer TIMER0 */ LEDC_TIMER1, /*LEDC source timer TIMER1 */ LEDC_TIMER2, /*LEDC source timer TIMER2 */ LEDC_TIMER3, /*LEDC source timer TIMER3 */ } ledc_timer_t; + typedef enum { LEDC_CHANNEL_0 = 0, /*LEDC channel 0 */ LEDC_CHANNEL_1, /*LEDC channel 1 */ @@ -62,6 +67,7 @@ typedef enum { LEDC_CHANNEL_6, /*LEDC channel 6 */ LEDC_CHANNEL_7, /*LEDC channel 7 */ } ledc_channel_t; + typedef enum { LEDC_TIMER_10_BIT = 10, /*LEDC PWM depth 10Bit */ LEDC_TIMER_11_BIT = 11, /*LEDC PWM depth 11Bit */ diff --git a/components/driver/ledc.c b/components/driver/ledc.c index a5bf92f6f..3fd0f27af 100644 --- a/components/driver/ledc.c +++ b/components/driver/ledc.c @@ -20,7 +20,7 @@ #include "soc/gpio_sig_map.h" #include "driver/ledc.h" -//TODO: Move these debug options to menuconfig +//TODO: to use APIs in esp_log.h. #define LEDC_DBG_WARING_ENABLE (0) #define LEDC_DBG_ERROR_ENABLE (0) #define LEDC_INFO_ENABLE (0) @@ -64,31 +64,31 @@ static portMUX_TYPE ledc_spinlock = portMUX_INITIALIZER_UNLOCKED; -static int ledc_is_valid_channel(uint32_t channel) +static bool ledc_is_valid_channel(uint32_t channel) { if(channel > LEDC_CHANNEL_7) { LEDC_ERROR("LEDC CHANNEL ERR: %d\n",channel); - return 0; + return false; } - return 1; + return true; } -static int ledc_is_valid_mode(uint32_t mode) +static bool ledc_is_valid_mode(uint32_t mode) { if(mode >= LEDC_SPEED_MODE_MAX) { LEDC_ERROR("LEDC MODE ERR: %d\n",mode); - return 0; + return false; } - return 1; + return true; } -static int ledc_is_valid_timer(int timer) +static bool ledc_is_valid_timer(int timer) { if(timer > LEDC_TIMER3) { LEDC_ERROR("LEDC TIMER ERR: %d\n", timer); - return 0; + return false; } - return 1; + return true; } esp_err_t ledc_timer_config(ledc_mode_t speed_mode, ledc_timer_t timer_sel, uint32_t div_num, uint32_t bit_num, ledc_clk_src_t clk_src)