esp32s2: Add support to LEDC PWM

This commit is contained in:
Alan Carvalho de Assis
2023-01-31 16:17:18 -03:00
committed by Xiang Xiao
parent d7b66adbeb
commit 39729bb635
5 changed files with 3736 additions and 0 deletions
+93
View File
@@ -442,6 +442,14 @@ config ESP32S2_I2C1
select ESP32S2_I2C
select I2C
config ESP32S2_LEDC
bool "LEDC (PWM)"
default n
select PWM
select ARCH_HAVE_PWM_MULTICHAN
---help---
Enable support to PWM on ESP32S2 using LEDC peripheral.
config ESP32S2_RT_TIMER
bool "Real-time Timer"
select ESP32S2_TIMER
@@ -869,6 +877,91 @@ config ESP32S2_FREERUN
endmenu # Timer/Counter Configuration
menu "LEDC Configuration"
depends on ESP32S2_LEDC
menuconfig ESP32S2_LEDC_TIM0
bool "Timer 0"
default n
if ESP32S2_LEDC_TIM0
config ESP32S2_LEDC_TIM0_CHANNELS
int "Number of Timer 0 channels"
default 2
endif # ESP32S2_LEDC_TIM0
menuconfig ESP32S2_LEDC_TIM1
bool "Timer 1"
default n
if ESP32S2_LEDC_TIM1
config ESP32S2_LEDC_TIM1_CHANNELS
int "Number of Timer 1 channels"
default 2
endif # ESP32S2_LEDC_TIM1
menuconfig ESP32S2_LEDC_TIM2
bool "Timer 2"
default n
if ESP32S2_LEDC_TIM2
config ESP32S2_LEDC_TIM2_CHANNELS
int "Number of Timer 2 channels"
default 2
endif # ESP32S2_LEDC_TIM2
menuconfig ESP32S2_LEDC_TIM3
bool "Timer 3"
default n
if ESP32S2_LEDC_TIM3
config ESP32S2_LEDC_TIM3_CHANNELS
int "Number of Timer 3 channels"
default 2
endif # ESP32S2_LEDC_TIM2
config ESP32S2_LEDC_CHANNEL0_PIN
int "Channel 0 pin"
default 2
config ESP32S2_LEDC_CHANNEL1_PIN
int "Channel 1 pin"
default 3
config ESP32S2_LEDC_CHANNEL2_PIN
int "Channel 2 pin"
default 4
config ESP32S2_LEDC_CHANNEL3_PIN
int "Channel 3 pin"
default 5
config ESP32S2_LEDC_CHANNEL4_PIN
int "Channel 4 pin"
default 6
config ESP32S2_LEDC_CHANNEL5_PIN
int "Channel 5 pin"
default 7
config ESP32S2_LEDC_CHANNEL6_PIN
int "Channel 6 pin"
default 8
config ESP32S2_LEDC_CHANNEL7_PIN
int "Channel 7 pin"
default 9
endmenu # LEDC configuration
config ESP32S2_HAVE_OTA_PARTITION
bool
default n
+4
View File
@@ -60,6 +60,10 @@ ifeq ($(CONFIG_ESP32S2_I2S),y)
CHIP_CSRCS += esp32s2_i2s.c
endif
ifeq ($(CONFIG_ESP32S2_LEDC),y)
CHIP_CSRCS += esp32s2_ledc.c
endif
ifeq ($(CONFIG_ESP32S2_SPI),y)
CHIP_CSRCS += esp32s2_spi.c
endif
File diff suppressed because it is too large Load Diff
+52
View File
@@ -0,0 +1,52 @@
/****************************************************************************
* arch/xtensa/src/esp32s2/esp32s2_ledc.h
*
* 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.
*
****************************************************************************/
#ifndef __ARCH_XTENSA_SRC_ESP32S2_ESP32S2_LEDC_H
#define __ARCH_XTENSA_SRC_ESP32S2_ESP32S2_LEDC_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/timers/pwm.h>
/****************************************************************************
* Public functions
****************************************************************************/
/****************************************************************************
* Name: esp32s2_ledc_init
*
* Description:
* Initialize one LEDC timer for use with the upper_level PWM driver.
*
* Input Parameters:
* timer - A number identifying the timer use.
*
* Returned Value:
* On success, a pointer to the ESP32S2-C3 LEDC lower half PWM driver is
* returned. NULL is returned on any failure.
*
****************************************************************************/
struct pwm_lowerhalf_s *esp32s2_ledc_init(int timer);
#endif /* __ARCH_RISCV_SRC_ESP32S2_ESP32S2_LEDC_H */
File diff suppressed because it is too large Load Diff