xtensa/esp32: Reorganize the timer logic for wireless use
This commit is contained in:
parent
f44675879c
commit
0c440cfdfe
@ -57,6 +57,7 @@
|
||||
#define RT_TIMER_TASK_STACK_SIZE CONFIG_ESP32_RT_TIMER_TASK_STACK_SIZE
|
||||
|
||||
#define ESP32_TIMER_PRESCALER (APB_CLK_FREQ / (1000 * 1000))
|
||||
#define ESP32_RT_TIMER 0 /* Timer 0 */
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
@ -597,7 +598,7 @@ int esp32_rt_timer_init(void)
|
||||
irqstate_t flags;
|
||||
struct esp32_tim_dev_s *tim;
|
||||
|
||||
tim = esp32_tim0_init();
|
||||
tim = esp32_tim_init(ESP32_RT_TIMER);
|
||||
if (!tim)
|
||||
{
|
||||
tmrerr("ERROR: Failed to initialize ESP32 timer0\n");
|
||||
@ -669,6 +670,7 @@ void esp32_rt_timer_deinit(void)
|
||||
flags = enter_critical_section();
|
||||
|
||||
ESP32_TIM_STOP(s_esp32_tim_dev);
|
||||
esp32_tim_deinit(s_esp32_tim_dev);
|
||||
s_esp32_tim_dev = NULL;
|
||||
|
||||
leave_critical_section(flags);
|
||||
|
@ -732,9 +732,7 @@ static int esp32_tim_checkint(FAR struct esp32_tim_dev_s *dev)
|
||||
* Name: esp32_tim_init
|
||||
*
|
||||
* Description:
|
||||
* Initialize TIMER device, if software real-time timer
|
||||
* (CONFIG_ESP32_RT_TIMER) is enabled, then timer0 can't
|
||||
* be initialized by this function directly.
|
||||
* Initialize TIMER device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -746,7 +744,7 @@ FAR struct esp32_tim_dev_s *esp32_tim_init(int timer)
|
||||
|
||||
switch (timer)
|
||||
{
|
||||
#if defined(CONFIG_ESP32_TIMER0) && !defined(CONFIG_ESP32_RT_TIMER)
|
||||
#ifdef CONFIG_ESP32_TIMER0
|
||||
case 0:
|
||||
{
|
||||
tim = &g_esp32_tim0_priv;
|
||||
@ -819,29 +817,3 @@ void esp32_tim_deinit(FAR struct esp32_tim_dev_s *dev)
|
||||
|
||||
tim->inuse = false;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_tim0_init
|
||||
*
|
||||
* Description:
|
||||
* Initialize TIMER0 device, this function is only used by software
|
||||
* real-time timer(esp32_rt_timer.c).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP32_RT_TIMER
|
||||
|
||||
FAR struct esp32_tim_dev_s *esp32_tim0_init(void)
|
||||
{
|
||||
FAR struct esp32_tim_priv_s *tim = &g_esp32_tim0_priv;
|
||||
|
||||
if (tim->inuse == true)
|
||||
{
|
||||
tmrerr("ERROR: Timer0 is already in use\n");
|
||||
tim = NULL;
|
||||
}
|
||||
|
||||
return (FAR struct esp32_tim_dev_s *)tim;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ESP32_RT_TIMER */
|
||||
|
@ -116,6 +116,5 @@ struct esp32_tim_ops_s
|
||||
|
||||
FAR struct esp32_tim_dev_s *esp32_tim_init(int timer);
|
||||
void esp32_tim_deinit(FAR struct esp32_tim_dev_s *dev);
|
||||
FAR struct esp32_tim_dev_s *esp32_tim0_init(void);
|
||||
|
||||
#endif /* __ARCH_XTENSA_SRC_ESP32_ESP32_TIM_H */
|
||||
|
@ -202,7 +202,7 @@ int esp32_bringup(void)
|
||||
|
||||
#ifdef CONFIG_TIMER
|
||||
|
||||
#ifdef CONFIG_ESP32_TIMER0
|
||||
#if defined(CONFIG_ESP32_TIMER0) && !defined(CONFIG_ESP32_RT_TIMER)
|
||||
ret = esp32_timer_initialize("/dev/timer0", TIMER0);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -169,7 +169,7 @@ int esp32_bringup(void)
|
||||
|
||||
#ifdef CONFIG_TIMER
|
||||
|
||||
#ifdef CONFIG_ESP32_TIMER0
|
||||
#if defined(CONFIG_ESP32_TIMER0) && !defined(CONFIG_ESP32_RT_TIMER)
|
||||
ret = esp32_timer_initialize("/dev/timer0", TIMER0);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -189,7 +189,7 @@ int esp32_bringup(void)
|
||||
|
||||
#ifdef CONFIG_TIMER
|
||||
|
||||
#ifdef CONFIG_ESP32_TIMER0
|
||||
#if defined(CONFIG_ESP32_TIMER0) && !defined(CONFIG_ESP32_RT_TIMER)
|
||||
ret = esp32_timer_initialize("/dev/timer0", TIMER0);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user