mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 12:08:36 +08:00
esp32s3-devkit: Initialize Oneshot timer on bringup
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
This commit is contained in:
parent
add99fead3
commit
71e8727397
2 changed files with 122 additions and 1 deletions
|
@ -27,10 +27,21 @@
|
|||
#include <sys/types.h>
|
||||
#include <debug.h>
|
||||
|
||||
#ifdef CONFIG_ONESHOT
|
||||
#include <nuttx/timers/oneshot.h>
|
||||
#ifdef CONFIG_CPULOAD_ONESHOT
|
||||
#include <nuttx/clock.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "esp32s3_board_tim.h"
|
||||
#include "esp32s3_tim.h"
|
||||
#include "esp32s3_tim_lowerhalf.h"
|
||||
|
||||
#ifdef CONFIG_ONESHOT
|
||||
#include "esp32s3_oneshot.h"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
@ -39,6 +50,47 @@
|
|||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: config_oneshot_timer
|
||||
*
|
||||
* Description:
|
||||
* Configure the oneshot timer driver.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; A negated errno value is returned
|
||||
* to indicate the nature of any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ONESHOT
|
||||
static int config_oneshot_timer(int timer, uint16_t resolution)
|
||||
{
|
||||
int ret = OK;
|
||||
struct oneshot_lowerhalf_s *os_lower = NULL;
|
||||
|
||||
os_lower = oneshot_initialize(timer, resolution);
|
||||
if (os_lower == NULL)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize oneshot timer.\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_CPULOAD_ONESHOT)
|
||||
/* Configure the oneshot timer to support CPU load measurement */
|
||||
|
||||
nxsched_oneshot_extclk(os_lower);
|
||||
#else
|
||||
ret = oneshot_register("/dev/oneshot", os_lower);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to register oneshot device: %d\n", ret);
|
||||
}
|
||||
#endif /* CONFIG_CPULOAD_ONESHOT */
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_tim_init
|
||||
*
|
||||
|
@ -55,7 +107,7 @@ int board_tim_init(void)
|
|||
{
|
||||
int ret = OK;
|
||||
|
||||
#if defined(CONFIG_ESP32S3_TIMER0)
|
||||
#if defined(CONFIG_ESP32S3_TIMER0) && !defined(CONFIG_ONESHOT)
|
||||
ret = esp32s3_timer_initialize("/dev/timer0", ESP32S3_TIMER0);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -87,5 +139,16 @@ int board_tim_init(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ONESHOT) && defined(CONFIG_ESP32S3_TIMER0)
|
||||
/* Now register one oneshot driver */
|
||||
|
||||
ret = config_oneshot_timer(ESP32S3_TIMER0, ONESHOT_RESOLUTION_US);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize oneshot timer: %d\n", ret);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ONESHOT */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
#
|
||||
# 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_NSH_CMDPARMS is not set
|
||||
CONFIG_ALARM_ARCH=y
|
||||
CONFIG_ARCH="xtensa"
|
||||
CONFIG_ARCH_BOARD="esp32s3-devkit"
|
||||
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_ONESHOT=y
|
||||
CONFIG_ESP32S3_TIMER0=y
|
||||
CONFIG_ESP32S3_TIMER1=y
|
||||
CONFIG_ESP32S3_TIMER2=y
|
||||
CONFIG_ESP32S3_TIMER3=y
|
||||
CONFIG_ESP32S3_UART0=y
|
||||
CONFIG_EXAMPLES_ONESHOT=y
|
||||
CONFIG_EXAMPLES_TIMER=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_MM_REGIONS=3
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_ONESHOT=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
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_TIMER=y
|
||||
CONFIG_TIMER_ARCH=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
Loading…
Reference in a new issue