acassis commented on a change in pull request #5187:
URL: https://github.com/apache/incubator-nuttx/pull/5187#discussion_r780233682



##########
File path: arch/xtensa/src/esp32/esp32_ledc.c
##########
@@ -0,0 +1,812 @@
+/****************************************************************************
+ * arch/xtensa/src/esp32/esp32_ledc.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <inttypes.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <debug.h>
+#include <errno.h>
+
+#include "esp32_clockconfig.h"
+#include "esp32_gpio.h"
+#include "esp32_ledc.h"
+
+#include "xtensa.h"
+#include "hardware/esp32_ledc.h"
+#include "hardware/esp32_dport.h"
+#include "hardware/esp32_gpio_sigmap.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* LEDC total timers */
+
+#define LEDC_TIMERS               (4)
+
+/* LEDC total channels */
+
+#if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS > 1
+#  define LEDC_CHANNELS           (8)
+#else
+#  define LEDC_CHANNELS           (4)
+#endif
+
+/* LEDC timer0 channels and offset */
+
+#ifdef CONFIG_ESP32_LEDC_TIM0
+#  if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS > 1
+#    define LEDC_TIM0_CHANS       CONFIG_ESP32_LEDC_TIM0_CHANNELS
+#  else
+#    define LEDC_TIM0_CHANS       (1)
+#  endif
+#    define LEDC_TIM0_CHANS_OFF   (0)
+#endif
+
+/* LEDC timer1 channels and offset */
+
+#ifdef CONFIG_ESP32_LEDC_TIM1
+#  if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS > 1
+#    define LEDC_TIM1_CHANS       CONFIG_ESP32_LEDC_TIM1_CHANNELS
+#  else
+#    define LEDC_TIM1_CHANS       (1)
+#  endif
+#  define LEDC_TIM1_CHANS_OFF     (LEDC_TIM0_CHANS_OFF + LEDC_TIM0_CHANS)
+#endif
+
+/* LEDC timer2 channels and offset */
+
+#ifdef CONFIG_ESP32_LEDC_TIM2
+#  if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS > 1

Review comment:
       Unfortunately we cannot remove this defined(CONFIG_PWM_NCHANNELS), 
otherwise it will generate a warning when PWM_NCHANNELS is not used:
   ```
   chip/esp32_ledc.c:52:5: warning: "CONFIG_PWM_NCHANNELS" is not defined, 
evaluates to 0 [-Wundef]
    #if CONFIG_PWM_NCHANNELS > 1
        ^~~~~~~~~~~~~~~~~~~~
   ```
   When "#if defined(CONFIG_PWM_NCHANNELS) && ..." is present the second part 
is not tested and the warning doesn't show up!




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to