mirror of
https://github.com/apache/nuttx.git
synced 2026-05-29 04:19:37 +08:00
esp32s3-devkit: Add support LED PWM initialization
This commit is contained in:
committed by
Xiang Xiao
parent
453d9688c7
commit
63a847ebca
@@ -158,7 +158,7 @@ struct esp32s3_ledc_s
|
|||||||
const uint8_t num; /* Timer ID */
|
const uint8_t num; /* Timer ID */
|
||||||
|
|
||||||
const uint8_t channels; /* Timer channels number */
|
const uint8_t channels; /* Timer channels number */
|
||||||
struct esp32s3_ledc_chan_s *chans; /* Timer channels pointer */
|
struct esp32s3_ledc_chan_s *chans; /* Timer channels pointer */
|
||||||
|
|
||||||
uint32_t frequency; /* Timer current frequency */
|
uint32_t frequency; /* Timer current frequency */
|
||||||
uint32_t reload; /* Timer current reload */
|
uint32_t reload; /* Timer current reload */
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
#
|
||||||
|
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||||
|
#
|
||||||
|
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||||
|
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||||
|
# modifications.
|
||||||
|
#
|
||||||
|
# CONFIG_ARCH_LEDS is not set
|
||||||
|
# CONFIG_NSH_ARGCAT is not set
|
||||||
|
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||||
|
CONFIG_ARCH="xtensa"
|
||||||
|
CONFIG_ARCH_BOARD="esp32s3-devkit"
|
||||||
|
CONFIG_ARCH_BOARD_COMMON=y
|
||||||
|
CONFIG_ARCH_BOARD_ESP32S3_DEVKIT=y
|
||||||
|
CONFIG_ARCH_CHIP="esp32s3"
|
||||||
|
CONFIG_ARCH_CHIP_ESP32S3=y
|
||||||
|
CONFIG_ARCH_CHIP_ESP32S3WROOM1=y
|
||||||
|
CONFIG_ARCH_STACKDUMP=y
|
||||||
|
CONFIG_ARCH_XTENSA=y
|
||||||
|
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||||
|
CONFIG_BUILTIN=y
|
||||||
|
CONFIG_DEBUG_FULLOPT=y
|
||||||
|
CONFIG_DEBUG_SYMBOLS=y
|
||||||
|
CONFIG_ESP32S3_LEDC=y
|
||||||
|
CONFIG_ESP32S3_LEDC_TIM0=y
|
||||||
|
CONFIG_ESP32S3_LEDC_TIM1=y
|
||||||
|
CONFIG_ESP32S3_LEDC_TIM2=y
|
||||||
|
CONFIG_ESP32S3_LEDC_TIM3=y
|
||||||
|
CONFIG_ESP32S3_UART0=y
|
||||||
|
CONFIG_EXAMPLES_PWM=y
|
||||||
|
CONFIG_FS_PROCFS=y
|
||||||
|
CONFIG_HAVE_CXX=y
|
||||||
|
CONFIG_HAVE_CXXINITIALIZE=y
|
||||||
|
CONFIG_IDLETHREAD_STACKSIZE=3072
|
||||||
|
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||||
|
CONFIG_INTELHEX_BINARY=y
|
||||||
|
CONFIG_NSH_ARCHINIT=y
|
||||||
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
|
CONFIG_NSH_FILEIOSIZE=512
|
||||||
|
CONFIG_NSH_LINELEN=64
|
||||||
|
CONFIG_NSH_READLINE=y
|
||||||
|
CONFIG_PREALLOC_TIMERS=4
|
||||||
|
CONFIG_RAM_SIZE=114688
|
||||||
|
CONFIG_RAM_START=0x20000000
|
||||||
|
CONFIG_RR_INTERVAL=200
|
||||||
|
CONFIG_SCHED_WAITPID=y
|
||||||
|
CONFIG_START_DAY=6
|
||||||
|
CONFIG_START_MONTH=12
|
||||||
|
CONFIG_START_YEAR=2011
|
||||||
|
CONFIG_SYSTEM_NSH=y
|
||||||
|
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||||
@@ -41,6 +41,10 @@ ifeq ($(CONFIG_ESP32S3_SPI),y)
|
|||||||
CSRCS += esp32s3_board_spi.c
|
CSRCS += esp32s3_board_spi.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_PWM),y)
|
||||||
|
CSRCS += esp32s3_ledc.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_LCD_ST7735),y)
|
ifeq ($(CONFIG_LCD_ST7735),y)
|
||||||
CSRCS += esp32s3_st7735.c
|
CSRCS += esp32s3_st7735.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -133,5 +133,17 @@ int board_bmp180_initialize(int devno, int busno);
|
|||||||
int esp32s3_djoy_initialize(void);
|
int esp32s3_djoy_initialize(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp32s3_ledc_setup
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize LEDC PWM and register the PWM device.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP32S3_LEDC
|
||||||
|
int esp32s3_pwm_setup(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __ASSEMBLY__ */
|
#endif /* __ASSEMBLY__ */
|
||||||
#endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_DEVKIT_SRC_ESP32S3_DEVKIT_H */
|
#endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_DEVKIT_SRC_ESP32S3_DEVKIT_H */
|
||||||
|
|||||||
@@ -66,6 +66,10 @@
|
|||||||
# include "esp32s3_efuse.h"
|
# include "esp32s3_efuse.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP32S3_LEDC
|
||||||
|
# include "esp32s3_ledc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "esp32s3-devkit.h"
|
#include "esp32s3-devkit.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -119,6 +123,14 @@ int esp32s3_bringup(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP32S3_LEDC
|
||||||
|
ret = esp32s3_pwm_setup();
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: esp32s3_pwm_setup() failed: %d\n", ret);
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_ESP32S3_LEDC */
|
||||||
|
|
||||||
#ifdef CONFIG_ESP32S3_TIMER
|
#ifdef CONFIG_ESP32S3_TIMER
|
||||||
/* Configure general purpose timers */
|
/* Configure general purpose timers */
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,139 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_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 <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/board.h>
|
||||||
|
#include <nuttx/timers/pwm.h>
|
||||||
|
|
||||||
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
|
#include "chip.h"
|
||||||
|
#include "esp32s3_ledc.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp32s3_pwm_setup
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize LEDC PWM and register the PWM device.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int esp32s3_pwm_setup(void)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
struct pwm_lowerhalf_s *pwm;
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP32S3_LEDC_TIM0
|
||||||
|
pwm = esp32s3_ledc_init(0);
|
||||||
|
if (!pwm)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: Failed to get the LEDC PWM 0 lower half\n");
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Register the PWM driver at "/dev/pwm0" */
|
||||||
|
|
||||||
|
ret = pwm_register("/dev/pwm0", pwm);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: pwm_register failed: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP32S3_LEDC_TIM1
|
||||||
|
pwm = esp32s3_ledc_init(1);
|
||||||
|
if (!pwm)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: Failed to get the LEDC PWM 1 lower half\n");
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Register the PWM driver at "/dev/pwm1" */
|
||||||
|
|
||||||
|
ret = pwm_register("/dev/pwm1", pwm);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: pwm_register failed: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP32S3_LEDC_TIM2
|
||||||
|
pwm = esp32s3_ledc_init(2);
|
||||||
|
if (!pwm)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: Failed to get the LEDC PWM 2 lower half\n");
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Register the PWM driver at "/dev/pwm2" */
|
||||||
|
|
||||||
|
ret = pwm_register("/dev/pwm2", pwm);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: pwm_register failed: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP32S3_LEDC_TIM3
|
||||||
|
pwm = esp32s3_ledc_init(3);
|
||||||
|
if (!pwm)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: Failed to get the LEDC PWM 3 lower half\n");
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Register the PWM driver at "/dev/pwm3" */
|
||||||
|
|
||||||
|
ret = pwm_register("/dev/pwm3", pwm);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: pwm_register failed: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* May not be used if none LEDC TIMx is enabled */
|
||||||
|
|
||||||
|
UNUSED(ret);
|
||||||
|
UNUSED(pwm);
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user