arch/xtensa/esp32_tim_lowerhalf.c: Use device specific locks.
Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
This commit is contained in:
parent
ff705586bb
commit
19a096cdfe
@ -23,21 +23,24 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/timers/timer.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/timers/timer.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
|
||||
#include "xtensa.h"
|
||||
|
||||
#include "hardware/esp32_soc.h"
|
||||
|
||||
#include "esp32_tim.h"
|
||||
#include "esp32_clockconfig.h"
|
||||
#include "esp32_tim.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@ -53,12 +56,13 @@
|
||||
|
||||
struct esp32_timer_lowerhalf_s
|
||||
{
|
||||
const struct timer_ops_s *ops; /* Lower half operations */
|
||||
struct esp32_tim_dev_s *tim; /* esp32 timer driver */
|
||||
tccb_t callback; /* Current user interrupt callback */
|
||||
void *arg; /* Argument passed to upper half callback */
|
||||
bool started; /* True: Timer has been started */
|
||||
void *upper; /* Pointer to watchdog_upperhalf_s */
|
||||
const struct timer_ops_s *ops; /* Lower half operations */
|
||||
struct esp32_tim_dev_s *tim; /* esp32 timer driver */
|
||||
tccb_t callback; /* Current user interrupt callback */
|
||||
void *arg; /* Argument passed to upper half callback */
|
||||
bool started; /* True: Timer has been started */
|
||||
void *upper; /* Pointer to watchdog_upperhalf_s */
|
||||
spinlock_t lock; /* Device specific lock */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@ -247,9 +251,9 @@ static int esp32_timer_start(struct timer_lowerhalf_s *lower)
|
||||
|
||||
if (priv->callback != NULL)
|
||||
{
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->lock);
|
||||
ret = ESP32_TIM_SETISR(priv->tim, esp32_timer_handler, priv);
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->lock, flags);
|
||||
if (ret != OK)
|
||||
{
|
||||
goto errout;
|
||||
@ -300,9 +304,11 @@ static int esp32_timer_stop(struct timer_lowerhalf_s *lower)
|
||||
}
|
||||
|
||||
ESP32_TIM_DISABLEINT(priv->tim);
|
||||
flags = enter_critical_section();
|
||||
|
||||
flags = spin_lock_irqsave(&priv->lock);
|
||||
ret = ESP32_TIM_SETISR(priv->tim, NULL, NULL);
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->lock, flags);
|
||||
|
||||
ESP32_TIM_STOP(priv->tim);
|
||||
|
||||
priv->started = false;
|
||||
@ -467,7 +473,7 @@ static void esp32_timer_setcallback(struct timer_lowerhalf_s *lower,
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->lock);
|
||||
|
||||
/* There is a user callback and the timer has already been started */
|
||||
|
||||
@ -482,7 +488,7 @@ static void esp32_timer_setcallback(struct timer_lowerhalf_s *lower,
|
||||
ret = ESP32_TIM_SETISR(priv->tim, NULL, NULL);
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->lock, flags);
|
||||
assert(ret == OK);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user