esp32s2-saola-1: Add initialization to LEDC PWM
This commit is contained in:
parent
39729bb635
commit
94970f32d7
@ -158,7 +158,7 @@ struct esp32s2_ledc_s
|
||||
const uint8_t num; /* Timer ID */
|
||||
|
||||
const uint8_t channels; /* Timer channels number */
|
||||
struct esp32s2_ledc_chan_s *chans; /* Timer channels pointer */
|
||||
struct esp32s2_ledc_chan_s *chans; /* Timer channels pointer */
|
||||
|
||||
uint32_t frequency; /* Timer current frequency */
|
||||
uint32_t reload; /* Timer current reload */
|
||||
|
@ -0,0 +1,49 @@
|
||||
#
|
||||
# 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="esp32s2-saola-1"
|
||||
CONFIG_ARCH_BOARD_COMMON=y
|
||||
CONFIG_ARCH_BOARD_ESP32S2_SAOLA_1=y
|
||||
CONFIG_ARCH_CHIP="esp32s2"
|
||||
CONFIG_ARCH_CHIP_ESP32S2=y
|
||||
CONFIG_ARCH_CHIP_ESP32S2WROVER=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_XTENSA=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_ESP32S2_LEDC=y
|
||||
CONFIG_ESP32S2_LEDC_TIM0=y
|
||||
CONFIG_ESP32S2_LEDC_TIM1=y
|
||||
CONFIG_ESP32S2_LEDC_TIM2=y
|
||||
CONFIG_ESP32S2_LEDC_TIM3=y
|
||||
CONFIG_ESP32S2_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
|
@ -33,6 +33,10 @@ ifeq ($(CONFIG_DEV_GPIO),y)
|
||||
CSRCS += esp32s2_gpio.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_PWM),y)
|
||||
CSRCS += esp32s2_ledc.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ONESHOT),y)
|
||||
CSRCS += esp32s2_oneshot.c
|
||||
endif
|
||||
|
@ -196,5 +196,17 @@ int board_i2sdev_initialize(bool enable_tx, bool enable_rx);
|
||||
int esp32s2_cs4344_initialize(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s2_ledc_setup
|
||||
*
|
||||
* Description:
|
||||
* Initialize LEDC PWM and register the PWM device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP32S2_LEDC
|
||||
int esp32s2_pwm_setup(void);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARDS_XTENSA_ESP32S2_ESP32S2_SAOLA_1_SRC_ESP32S2_SAOLA_1_H */
|
||||
|
@ -62,6 +62,10 @@
|
||||
# include "esp32s2_efuse.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S2_LEDC
|
||||
# include "esp32s2_ledc.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_WATCHDOG
|
||||
# include "esp32s2_board_wdt.h"
|
||||
#endif
|
||||
@ -133,6 +137,14 @@ int esp32s2_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S2_LEDC
|
||||
ret = esp32s2_pwm_setup();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: esp32s2_pwm_setup() failed: %d\n", ret);
|
||||
}
|
||||
#endif /* CONFIG_ESP32S2_LEDC */
|
||||
|
||||
#ifdef CONFIG_DEV_GPIO
|
||||
ret = esp32s2_gpio_init();
|
||||
if (ret < 0)
|
||||
|
139
boards/xtensa/esp32s2/esp32s2-saola-1/src/esp32s2_ledc.c
Normal file
139
boards/xtensa/esp32s2/esp32s2-saola-1/src/esp32s2_ledc.c
Normal file
@ -0,0 +1,139 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32s2/esp32s2-saola-1/src/esp32s2_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 "esp32s2_ledc.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s2_pwm_setup
|
||||
*
|
||||
* Description:
|
||||
* Initialize LEDC PWM and register the PWM device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int esp32s2_pwm_setup(void)
|
||||
{
|
||||
int ret;
|
||||
struct pwm_lowerhalf_s *pwm;
|
||||
|
||||
#ifdef CONFIG_ESP32S2_LEDC_TIM0
|
||||
pwm = esp32s2_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_ESP32S2_LEDC_TIM1
|
||||
pwm = esp32s2_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_ESP32S2_LEDC_TIM2
|
||||
pwm = esp32s2_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_ESP32S2_LEDC_TIM3
|
||||
pwm = esp32s2_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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user