esp32/esp32_oneshot_lowerhalf.c: Use device specific locks.
Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
This commit is contained in:
parent
698af43d78
commit
0af9a49d9c
@ -35,6 +35,7 @@
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/timers/oneshot.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
|
||||
#include "esp32_oneshot.h"
|
||||
|
||||
@ -60,6 +61,7 @@ struct esp32_oneshot_lowerhalf_s
|
||||
oneshot_callback_t callback; /* Upper half Interrupt callback */
|
||||
void *arg; /* Argument passed to handler */
|
||||
uint16_t resolution;
|
||||
spinlock_t lock; /* Device specific lock */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@ -208,12 +210,12 @@ static int esp32_lh_start(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Save the callback information and start the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->lock);
|
||||
priv->callback = callback;
|
||||
priv->arg = arg;
|
||||
ret = esp32_oneshot_start(&priv->oneshot,
|
||||
esp32_oneshot_lh_handler, priv, ts);
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->lock, flags);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -259,11 +261,11 @@ static int esp32_lh_cancel(struct oneshot_lowerhalf_s *lower,
|
||||
|
||||
/* Cancel the timer */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->lock);
|
||||
ret = esp32_oneshot_cancel(&priv->oneshot, ts);
|
||||
priv->callback = NULL;
|
||||
priv->arg = NULL;
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->lock, flags);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user