mirror of
https://github.com/apache/nuttx.git
synced 2026-09-20 21:06:58 +08:00
risc-v/espressif: Initialize HR Timer where it is required
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
This commit is contained in:
committed by
Alan Carvalho de Assis
parent
ebe4ab8894
commit
8e83379b84
@@ -648,13 +648,22 @@ void IRAM_ATTR esp_hr_timer_calibration(uint64_t time_us)
|
||||
|
||||
int esp_hr_timer_init(void)
|
||||
{
|
||||
struct esp_hr_timer_context_s *priv = &g_hr_timer_context;
|
||||
static bool g_hr_timer_initialized = false;
|
||||
struct esp_hr_timer_context_s *priv;
|
||||
int pid;
|
||||
|
||||
int pid = kthread_create(CONFIG_ESPRESSIF_HR_TIMER_TASK_NAME,
|
||||
CONFIG_ESPRESSIF_HR_TIMER_TASK_PRIORITY,
|
||||
CONFIG_ESPRESSIF_HR_TIMER_TASK_STACK_SIZE,
|
||||
esp_hr_timer_thread,
|
||||
NULL);
|
||||
if (g_hr_timer_initialized)
|
||||
{
|
||||
tmrinfo("HR Timer already initialized, skipping...\n");
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
pid = kthread_create(CONFIG_ESPRESSIF_HR_TIMER_TASK_NAME,
|
||||
CONFIG_ESPRESSIF_HR_TIMER_TASK_PRIORITY,
|
||||
CONFIG_ESPRESSIF_HR_TIMER_TASK_STACK_SIZE,
|
||||
esp_hr_timer_thread,
|
||||
NULL);
|
||||
if (pid < 0)
|
||||
{
|
||||
tmrerr("Failed to create HR Timer task=%d\n", pid);
|
||||
@@ -662,6 +671,8 @@ int esp_hr_timer_init(void)
|
||||
return pid;
|
||||
}
|
||||
|
||||
priv = &g_hr_timer_context;
|
||||
|
||||
list_initialize(&priv->runlist);
|
||||
list_initialize(&priv->toutlist);
|
||||
|
||||
@@ -714,5 +725,7 @@ int esp_hr_timer_init(void)
|
||||
|
||||
up_enable_irq(ESP_IRQ_SYSTIMER_TARGET2_EDGE);
|
||||
|
||||
return 0;
|
||||
g_hr_timer_initialized = true;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -863,7 +863,9 @@ int esp_rtc_driverinit(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* HR-Timer enabled */
|
||||
/* Enable HR-Timer */
|
||||
|
||||
VERIFY(esp_hr_timer_init());
|
||||
|
||||
g_hr_timer_enabled = true;
|
||||
|
||||
|
||||
@@ -46,10 +46,6 @@
|
||||
# include "esp_oneshot.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_HR_TIMER
|
||||
# include "esp_hr_timer.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RTC_DRIVER
|
||||
# include "esp_rtc.h"
|
||||
#endif
|
||||
@@ -141,14 +137,6 @@ int esp_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_HR_TIMER
|
||||
ret = esp_hr_timer_init();
|
||||
if (ret < 0)
|
||||
{
|
||||
_err("Failed to initialize HR timer: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RTC_DRIVER
|
||||
/* Initialize the RTC driver */
|
||||
|
||||
|
||||
@@ -46,10 +46,6 @@
|
||||
# include "esp_oneshot.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_HR_TIMER
|
||||
# include "esp_hr_timer.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RTC_DRIVER
|
||||
# include "esp_rtc.h"
|
||||
#endif
|
||||
@@ -141,14 +137,6 @@ int esp_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_HR_TIMER
|
||||
ret = esp_hr_timer_init();
|
||||
if (ret < 0)
|
||||
{
|
||||
_err("Failed to initialize HR timer: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RTC_DRIVER
|
||||
/* Initialize the RTC driver */
|
||||
|
||||
|
||||
@@ -46,10 +46,6 @@
|
||||
# include "esp_oneshot.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_HR_TIMER
|
||||
# include "esp_hr_timer.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RTC_DRIVER
|
||||
# include "esp_rtc.h"
|
||||
#endif
|
||||
@@ -141,14 +137,6 @@ int esp_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_HR_TIMER
|
||||
ret = esp_hr_timer_init();
|
||||
if (ret < 0)
|
||||
{
|
||||
_err("Failed to initialize HR timer: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RTC_DRIVER
|
||||
/* Initialize the RTC driver */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user