Procházet zdrojové kódy

Minor modification

1. add new line between typedefs
2. for param check functions, return bool if they are true/false
Wangjialin před 9 roky
rodič
revize
516ab36bbe
2 změnil soubory, kde provedl 16 přidání a 10 odebrání
  1. 6 0
      components/driver/include/driver/ledc.h
  2. 10 10
      components/driver/ledc.c

+ 6 - 0
components/driver/include/driver/ledc.h

@@ -34,24 +34,29 @@ typedef enum {
     //LEDC_LOW_SPEED_MODE,    /*LEDC low speed speed_mode */
     //LEDC_LOW_SPEED_MODE,    /*LEDC low speed speed_mode */
     LEDC_SPEED_MODE_MAX,
     LEDC_SPEED_MODE_MAX,
 } ledc_mode_t;
 } ledc_mode_t;
+
 typedef enum {
 typedef enum {
     LEDC_INTR_DISABLE = 0,    /*Disable LEDC interrupt */
     LEDC_INTR_DISABLE = 0,    /*Disable LEDC interrupt */
     LEDC_INTR_FADE_END,       /*Enable LEDC interrupt */
     LEDC_INTR_FADE_END,       /*Enable LEDC interrupt */
 } ledc_intr_type_t;
 } ledc_intr_type_t;
+
 typedef enum {
 typedef enum {
     LEDC_DUTY_DIR_DECREASE = 0,    /*LEDC duty decrease direction */
     LEDC_DUTY_DIR_DECREASE = 0,    /*LEDC duty decrease direction */
     LEDC_DUTY_DIR_INCREASE = 1,    /*LEDC duty increase direction */
     LEDC_DUTY_DIR_INCREASE = 1,    /*LEDC duty increase direction */
 } ledc_duty_direction_t;
 } ledc_duty_direction_t;
+
 typedef enum  {
 typedef enum  {
     LEDC_REF_TICK = 0, /*LEDC timer clock divided from reference tick(1Mhz) */
     LEDC_REF_TICK = 0, /*LEDC timer clock divided from reference tick(1Mhz) */
     LEDC_APB_CLK,      /*LEDC timer clock divided from APB clock(80Mhz)*/
     LEDC_APB_CLK,      /*LEDC timer clock divided from APB clock(80Mhz)*/
 } ledc_clk_src_t;
 } ledc_clk_src_t;
+
 typedef enum {
 typedef enum {
     LEDC_TIMER0 = 0, /*LEDC source timer TIMER0 */
     LEDC_TIMER0 = 0, /*LEDC source timer TIMER0 */
     LEDC_TIMER1,     /*LEDC source timer TIMER1 */
     LEDC_TIMER1,     /*LEDC source timer TIMER1 */
     LEDC_TIMER2,     /*LEDC source timer TIMER2 */
     LEDC_TIMER2,     /*LEDC source timer TIMER2 */
     LEDC_TIMER3,     /*LEDC source timer TIMER3 */
     LEDC_TIMER3,     /*LEDC source timer TIMER3 */
 } ledc_timer_t;
 } ledc_timer_t;
+
 typedef enum {
 typedef enum {
     LEDC_CHANNEL_0 = 0, /*LEDC channel 0 */
     LEDC_CHANNEL_0 = 0, /*LEDC channel 0 */
     LEDC_CHANNEL_1,     /*LEDC channel 1 */
     LEDC_CHANNEL_1,     /*LEDC channel 1 */
@@ -62,6 +67,7 @@ typedef enum {
     LEDC_CHANNEL_6,     /*LEDC channel 6 */
     LEDC_CHANNEL_6,     /*LEDC channel 6 */
     LEDC_CHANNEL_7,     /*LEDC channel 7 */
     LEDC_CHANNEL_7,     /*LEDC channel 7 */
 } ledc_channel_t;
 } ledc_channel_t;
+
 typedef enum {
 typedef enum {
     LEDC_TIMER_10_BIT = 10, /*LEDC PWM depth 10Bit */
     LEDC_TIMER_10_BIT = 10, /*LEDC PWM depth 10Bit */
     LEDC_TIMER_11_BIT = 11, /*LEDC PWM depth 11Bit */
     LEDC_TIMER_11_BIT = 11, /*LEDC PWM depth 11Bit */

+ 10 - 10
components/driver/ledc.c

@@ -20,7 +20,7 @@
 #include "soc/gpio_sig_map.h"
 #include "soc/gpio_sig_map.h"
 #include "driver/ledc.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_WARING_ENABLE (0)
 #define LEDC_DBG_ERROR_ENABLE  (0)
 #define LEDC_DBG_ERROR_ENABLE  (0)
 #define LEDC_INFO_ENABLE       (0)
 #define LEDC_INFO_ENABLE       (0)
@@ -64,31 +64,31 @@
 
 
 static portMUX_TYPE ledc_spinlock = portMUX_INITIALIZER_UNLOCKED;
 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) {
     if(channel > LEDC_CHANNEL_7) {
         LEDC_ERROR("LEDC CHANNEL ERR: %d\n",channel);
         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) {
     if(mode >= LEDC_SPEED_MODE_MAX) {
         LEDC_ERROR("LEDC MODE ERR: %d\n",mode);
         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) {
     if(timer > LEDC_TIMER3) {
         LEDC_ERROR("LEDC TIMER ERR: %d\n", timer);
         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)
 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)