mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
esp32_serial.c: Replace critical section by a device specific spin lock.
Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
This commit is contained in:
committed by
Masayuki Ishikawa
parent
803599faeb
commit
b5bb1fb8a3
@@ -41,6 +41,7 @@
|
|||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/fs/ioctl.h>
|
#include <nuttx/fs/ioctl.h>
|
||||||
#include <nuttx/serial/serial.h>
|
#include <nuttx/serial/serial.h>
|
||||||
|
#include <nuttx/spinlock.h>
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
@@ -268,6 +269,7 @@ struct esp32_dev_s
|
|||||||
#ifdef CONFIG_SERIAL_OFLOWCONTROL
|
#ifdef CONFIG_SERIAL_OFLOWCONTROL
|
||||||
bool oflow; /* Output flow control (CTS) enabled */
|
bool oflow; /* Output flow control (CTS) enabled */
|
||||||
#endif
|
#endif
|
||||||
|
spinlock_t lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -816,7 +818,7 @@ static void esp32_disableallints(struct esp32_dev_s *priv, uint32_t *intena)
|
|||||||
|
|
||||||
/* The following must be atomic */
|
/* The following must be atomic */
|
||||||
|
|
||||||
flags = enter_critical_section();
|
flags = spin_lock_irqsave(&priv->lock);
|
||||||
|
|
||||||
if (intena)
|
if (intena)
|
||||||
{
|
{
|
||||||
@@ -828,7 +830,7 @@ static void esp32_disableallints(struct esp32_dev_s *priv, uint32_t *intena)
|
|||||||
/* Disable all interrupts */
|
/* Disable all interrupts */
|
||||||
|
|
||||||
putreg32(0, UART_INT_ENA_REG(priv->config->id));
|
putreg32(0, UART_INT_ENA_REG(priv->config->id));
|
||||||
leave_critical_section(flags);
|
spin_unlock_irqrestore(&priv->lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -953,7 +955,7 @@ static int esp32_setup(struct uart_dev_s *dev)
|
|||||||
modifyreg32(UART_CONF1_REG(priv->config->id), 0, regval);
|
modifyreg32(UART_CONF1_REG(priv->config->id), 0, regval);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
return OK;
|
return OK;
|
||||||
@@ -1641,7 +1643,7 @@ static void esp32_rxint(struct uart_dev_s *dev, bool enable)
|
|||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
int regval;
|
int regval;
|
||||||
|
|
||||||
flags = enter_critical_section();
|
flags = spin_lock_irqsave(&priv->lock);
|
||||||
|
|
||||||
if (enable)
|
if (enable)
|
||||||
{
|
{
|
||||||
@@ -1666,7 +1668,7 @@ static void esp32_rxint(struct uart_dev_s *dev, bool enable)
|
|||||||
putreg32(regval, UART_INT_ENA_REG(priv->config->id));
|
putreg32(regval, UART_INT_ENA_REG(priv->config->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
leave_critical_section(flags);
|
spin_unlock_irqrestore(&priv->lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -1714,7 +1716,7 @@ static void esp32_txint(struct uart_dev_s *dev, bool enable)
|
|||||||
if (priv->txdma == false)
|
if (priv->txdma == false)
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
flags = enter_critical_section();
|
flags = spin_lock_irqsave(&priv->lock);
|
||||||
|
|
||||||
if (enable)
|
if (enable)
|
||||||
{
|
{
|
||||||
@@ -1742,7 +1744,7 @@ static void esp32_txint(struct uart_dev_s *dev, bool enable)
|
|||||||
(UART_TX_DONE_INT_ENA | UART_TXFIFO_EMPTY_INT_ENA), 0);
|
(UART_TX_DONE_INT_ENA | UART_TXFIFO_EMPTY_INT_ENA), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
leave_critical_section(flags);
|
spin_unlock_irqrestore(&priv->lock, flags);
|
||||||
#ifdef CONFIG_SERIAL_TXDMA
|
#ifdef CONFIG_SERIAL_TXDMA
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user