mirror of https://github.com/ARMmbed/mbed-os.git
[Nuvoton] Fix redundant call to UART IRQ handler
Honor RxIrq/TxIrq to avoid redundant call to UART IRQ handler. This is also to fix FPGA CI test mbed_hal_fpga_ci_test_shield-uart.pull/11152/head
parent
d46c6fea47
commit
09bf844d76
|
@ -85,9 +85,10 @@ static void serial_rx_enable_event(serial_t *obj, int event, uint8_t enable);
|
|||
static int serial_is_rx_complete(serial_t *obj);
|
||||
|
||||
static void serial_check_dma_usage(DMAUsage *dma_usage, int *dma_ch);
|
||||
static int serial_is_irq_en(serial_t *obj, SerialIrq irq);
|
||||
#endif
|
||||
|
||||
static int serial_is_irq_en(serial_t *obj, SerialIrq irq);
|
||||
|
||||
bool serial_can_deep_sleep(void);
|
||||
|
||||
static struct nu_uart_var uart0_var = {
|
||||
|
@ -531,7 +532,8 @@ static void uart_irq(serial_t *obj)
|
|||
if (uart_base->INTSTS & (UART_INTSTS_RDAINT_Msk | UART_INTSTS_RXTOINT_Msk)) {
|
||||
// Simulate clear of the interrupt flag. Temporarily disable the interrupt here and to be recovered on next read.
|
||||
UART_DISABLE_INT(uart_base, (UART_INTEN_RDAIEN_Msk | UART_INTEN_RXTOIEN_Msk));
|
||||
if (obj->serial.irq_handler) {
|
||||
if (obj->serial.irq_handler && serial_is_irq_en(obj, RxIrq)) {
|
||||
// Call irq_handler() only when RxIrq is enabled
|
||||
((uart_irq_handler) obj->serial.irq_handler)(obj->serial.irq_id, RxIrq);
|
||||
}
|
||||
}
|
||||
|
@ -539,7 +541,8 @@ static void uart_irq(serial_t *obj)
|
|||
if (uart_base->INTSTS & UART_INTSTS_THREINT_Msk) {
|
||||
// Simulate clear of the interrupt flag. Temporarily disable the interrupt here and to be recovered on next write.
|
||||
UART_DISABLE_INT(uart_base, UART_INTEN_THREIEN_Msk);
|
||||
if (obj->serial.irq_handler) {
|
||||
if (obj->serial.irq_handler && serial_is_irq_en(obj, TxIrq)) {
|
||||
// Call irq_handler() only when TxIrq is enabled
|
||||
((uart_irq_handler) obj->serial.irq_handler)(obj->serial.irq_id, TxIrq);
|
||||
}
|
||||
}
|
||||
|
@ -1179,6 +1182,8 @@ static void serial_check_dma_usage(DMAUsage *dma_usage, int *dma_ch)
|
|||
}
|
||||
}
|
||||
|
||||
#endif // #if DEVICE_SERIAL_ASYNCH
|
||||
|
||||
static int serial_is_irq_en(serial_t *obj, SerialIrq irq)
|
||||
{
|
||||
int inten_msk = 0;
|
||||
|
@ -1195,8 +1200,6 @@ static int serial_is_irq_en(serial_t *obj, SerialIrq irq)
|
|||
return !! inten_msk;
|
||||
}
|
||||
|
||||
#endif // #if DEVICE_SERIAL_ASYNCH
|
||||
|
||||
bool serial_can_deep_sleep(void)
|
||||
{
|
||||
bool sleep_allowed = 1;
|
||||
|
|
|
@ -81,9 +81,10 @@ static void serial_rx_enable_event(serial_t *obj, int event, uint8_t enable);
|
|||
static int serial_is_rx_complete(serial_t *obj);
|
||||
|
||||
static void serial_check_dma_usage(DMAUsage *dma_usage, int *dma_ch);
|
||||
static int serial_is_irq_en(serial_t *obj, SerialIrq irq);
|
||||
#endif
|
||||
|
||||
static int serial_is_irq_en(serial_t *obj, SerialIrq irq);
|
||||
|
||||
bool serial_can_deep_sleep(void);
|
||||
|
||||
static struct nu_uart_var uart0_var = {
|
||||
|
@ -464,7 +465,8 @@ static void uart_irq(serial_t *obj)
|
|||
if (uart_base->INTSTS & (UART_INTSTS_RDAINT_Msk | UART_INTSTS_RXTOINT_Msk)) {
|
||||
// Simulate clear of the interrupt flag. Temporarily disable the interrupt here and to be recovered on next read.
|
||||
UART_DISABLE_INT(uart_base, (UART_INTEN_RDAIEN_Msk | UART_INTEN_RXTOIEN_Msk));
|
||||
if (obj->serial.irq_handler) {
|
||||
if (obj->serial.irq_handler && serial_is_irq_en(obj, RxIrq)) {
|
||||
// Call irq_handler() only when RxIrq is enabled
|
||||
((uart_irq_handler) obj->serial.irq_handler)(obj->serial.irq_id, RxIrq);
|
||||
}
|
||||
}
|
||||
|
@ -472,7 +474,8 @@ static void uart_irq(serial_t *obj)
|
|||
if (uart_base->INTSTS & UART_INTSTS_THREINT_Msk) {
|
||||
// Simulate clear of the interrupt flag. Temporarily disable the interrupt here and to be recovered on next write.
|
||||
UART_DISABLE_INT(uart_base, UART_INTEN_THREIEN_Msk);
|
||||
if (obj->serial.irq_handler) {
|
||||
if (obj->serial.irq_handler && serial_is_irq_en(obj, TxIrq)) {
|
||||
// Call irq_handler() only when TxIrq is enabled
|
||||
((uart_irq_handler) obj->serial.irq_handler)(obj->serial.irq_id, TxIrq);
|
||||
}
|
||||
}
|
||||
|
@ -1102,6 +1105,8 @@ static void serial_check_dma_usage(DMAUsage *dma_usage, int *dma_ch)
|
|||
}
|
||||
}
|
||||
|
||||
#endif // #if DEVICE_SERIAL_ASYNCH
|
||||
|
||||
static int serial_is_irq_en(serial_t *obj, SerialIrq irq)
|
||||
{
|
||||
int inten_msk = 0;
|
||||
|
@ -1118,8 +1123,6 @@ static int serial_is_irq_en(serial_t *obj, SerialIrq irq)
|
|||
return !! inten_msk;
|
||||
}
|
||||
|
||||
#endif // #if DEVICE_SERIAL_ASYNCH
|
||||
|
||||
bool serial_can_deep_sleep(void)
|
||||
{
|
||||
bool sleep_allowed = 1;
|
||||
|
|
|
@ -85,9 +85,10 @@ static void serial_rx_enable_event(serial_t *obj, int event, uint8_t enable);
|
|||
static int serial_is_rx_complete(serial_t *obj);
|
||||
|
||||
static void serial_check_dma_usage(DMAUsage *dma_usage, int *dma_ch);
|
||||
static int serial_is_irq_en(serial_t *obj, SerialIrq irq);
|
||||
#endif
|
||||
|
||||
static int serial_is_irq_en(serial_t *obj, SerialIrq irq);
|
||||
|
||||
bool serial_can_deep_sleep(void);
|
||||
|
||||
static struct nu_uart_var uart0_var = {
|
||||
|
@ -519,7 +520,8 @@ static void uart_irq(serial_t *obj)
|
|||
if (uart_base->INTSTS & (UART_INTSTS_RDAINT_Msk | UART_INTSTS_RXTOINT_Msk)) {
|
||||
// Simulate clear of the interrupt flag. Temporarily disable the interrupt here and to be recovered on next read.
|
||||
UART_DISABLE_INT(uart_base, (UART_INTEN_RDAIEN_Msk | UART_INTEN_RXTOIEN_Msk));
|
||||
if (obj->serial.irq_handler) {
|
||||
if (obj->serial.irq_handler && serial_is_irq_en(obj, RxIrq)) {
|
||||
// Call irq_handler() only when RxIrq is enabled
|
||||
((uart_irq_handler) obj->serial.irq_handler)(obj->serial.irq_id, RxIrq);
|
||||
}
|
||||
}
|
||||
|
@ -527,7 +529,8 @@ static void uart_irq(serial_t *obj)
|
|||
if (uart_base->INTSTS & UART_INTSTS_THREINT_Msk) {
|
||||
// Simulate clear of the interrupt flag. Temporarily disable the interrupt here and to be recovered on next write.
|
||||
UART_DISABLE_INT(uart_base, UART_INTEN_THREIEN_Msk);
|
||||
if (obj->serial.irq_handler) {
|
||||
if (obj->serial.irq_handler && serial_is_irq_en(obj, TxIrq)) {
|
||||
// Call irq_handler() only when TxIrq is enabled
|
||||
((uart_irq_handler) obj->serial.irq_handler)(obj->serial.irq_id, TxIrq);
|
||||
}
|
||||
}
|
||||
|
@ -1154,6 +1157,8 @@ static void serial_check_dma_usage(DMAUsage *dma_usage, int *dma_ch)
|
|||
}
|
||||
}
|
||||
|
||||
#endif // #if DEVICE_SERIAL_ASYNCH
|
||||
|
||||
static int serial_is_irq_en(serial_t *obj, SerialIrq irq)
|
||||
{
|
||||
int inten_msk = 0;
|
||||
|
@ -1170,8 +1175,6 @@ static int serial_is_irq_en(serial_t *obj, SerialIrq irq)
|
|||
return !! inten_msk;
|
||||
}
|
||||
|
||||
#endif // #if DEVICE_SERIAL_ASYNCH
|
||||
|
||||
bool serial_can_deep_sleep(void)
|
||||
{
|
||||
bool sleep_allowed = 1;
|
||||
|
|
|
@ -74,9 +74,10 @@ static void serial_rx_enable_event(serial_t *obj, int event, uint8_t enable);
|
|||
static int serial_is_rx_complete(serial_t *obj);
|
||||
|
||||
static void serial_check_dma_usage(DMAUsage *dma_usage, int *dma_ch);
|
||||
static int serial_is_irq_en(serial_t *obj, SerialIrq irq);
|
||||
#endif
|
||||
|
||||
static int serial_is_irq_en(serial_t *obj, SerialIrq irq);
|
||||
|
||||
bool serial_can_deep_sleep(void);
|
||||
|
||||
static struct nu_uart_var uart0_var = {
|
||||
|
@ -426,7 +427,8 @@ static void uart_irq(serial_t *obj)
|
|||
if (uart_base->ISR & (UART_ISR_RDA_IS_Msk | UART_ISR_RTO_IS_Msk)) {
|
||||
// Simulate clear of the interrupt flag. Temporarily disable the interrupt here and to be recovered on next read.
|
||||
UART_DISABLE_INT(uart_base, (UART_IER_RDA_IE_Msk | UART_IER_RTO_IE_Msk));
|
||||
if (obj->serial.irq_handler) {
|
||||
if (obj->serial.irq_handler && serial_is_irq_en(obj, RxIrq)) {
|
||||
// Call irq_handler() only when RxIrq is enabled
|
||||
((uart_irq_handler) obj->serial.irq_handler)(obj->serial.irq_id, RxIrq);
|
||||
}
|
||||
}
|
||||
|
@ -434,7 +436,8 @@ static void uart_irq(serial_t *obj)
|
|||
if (uart_base->ISR & UART_ISR_THRE_IS_Msk) {
|
||||
// Simulate clear of the interrupt flag. Temporarily disable the interrupt here and to be recovered on next write.
|
||||
UART_DISABLE_INT(uart_base, UART_IER_THRE_IE_Msk);
|
||||
if (obj->serial.irq_handler) {
|
||||
if (obj->serial.irq_handler && serial_is_irq_en(obj, TxIrq)) {
|
||||
// Call irq_handler() only when TxIrq is enabled
|
||||
((uart_irq_handler) obj->serial.irq_handler)(obj->serial.irq_id, TxIrq);
|
||||
}
|
||||
}
|
||||
|
@ -1003,6 +1006,8 @@ static void serial_check_dma_usage(DMAUsage *dma_usage, int *dma_ch)
|
|||
}
|
||||
}
|
||||
|
||||
#endif // #if DEVICE_SERIAL_ASYNCH
|
||||
|
||||
static int serial_is_irq_en(serial_t *obj, SerialIrq irq)
|
||||
{
|
||||
int ier_msk = 0;
|
||||
|
@ -1019,8 +1024,6 @@ static int serial_is_irq_en(serial_t *obj, SerialIrq irq)
|
|||
return !! ier_msk;
|
||||
}
|
||||
|
||||
#endif // #if DEVICE_SERIAL_ASYNCH
|
||||
|
||||
bool serial_can_deep_sleep(void)
|
||||
{
|
||||
bool sleep_allowed = 1;
|
||||
|
|
|
@ -85,9 +85,10 @@ static void serial_rx_enable_event(serial_t *obj, int event, uint8_t enable);
|
|||
static int serial_is_rx_complete(serial_t *obj);
|
||||
|
||||
static void serial_check_dma_usage(DMAUsage *dma_usage, int *dma_ch);
|
||||
static int serial_is_irq_en(serial_t *obj, SerialIrq irq);
|
||||
#endif
|
||||
|
||||
static int serial_is_irq_en(serial_t *obj, SerialIrq irq);
|
||||
|
||||
bool serial_can_deep_sleep(void);
|
||||
|
||||
static struct nu_uart_var uart0_var = {
|
||||
|
@ -504,7 +505,8 @@ static void uart_irq(serial_t *obj)
|
|||
if (uart_base->INTSTS & (UART_INTSTS_RDAINT_Msk | UART_INTSTS_RXTOINT_Msk)) {
|
||||
// Simulate clear of the interrupt flag. Temporarily disable the interrupt here and to be recovered on next read.
|
||||
UART_DISABLE_INT(uart_base, (UART_INTEN_RDAIEN_Msk | UART_INTEN_RXTOIEN_Msk));
|
||||
if (obj->serial.irq_handler) {
|
||||
if (obj->serial.irq_handler && serial_is_irq_en(obj, RxIrq)) {
|
||||
// Call irq_handler() only when RxIrq is enabled
|
||||
((uart_irq_handler) obj->serial.irq_handler)(obj->serial.irq_id, RxIrq);
|
||||
}
|
||||
}
|
||||
|
@ -512,7 +514,8 @@ static void uart_irq(serial_t *obj)
|
|||
if (uart_base->INTSTS & UART_INTSTS_THREINT_Msk) {
|
||||
// Simulate clear of the interrupt flag. Temporarily disable the interrupt here and to be recovered on next write.
|
||||
UART_DISABLE_INT(uart_base, UART_INTEN_THREIEN_Msk);
|
||||
if (obj->serial.irq_handler) {
|
||||
if (obj->serial.irq_handler && serial_is_irq_en(obj, TxIrq)) {
|
||||
// Call irq_handler() only when TxIrq is enabled
|
||||
((uart_irq_handler) obj->serial.irq_handler)(obj->serial.irq_id, TxIrq);
|
||||
}
|
||||
}
|
||||
|
@ -1148,6 +1151,8 @@ static void serial_check_dma_usage(DMAUsage *dma_usage, int *dma_ch)
|
|||
}
|
||||
}
|
||||
|
||||
#endif // #if DEVICE_SERIAL_ASYNCH
|
||||
|
||||
static int serial_is_irq_en(serial_t *obj, SerialIrq irq)
|
||||
{
|
||||
int inten_msk = 0;
|
||||
|
@ -1164,8 +1169,6 @@ static int serial_is_irq_en(serial_t *obj, SerialIrq irq)
|
|||
return !! inten_msk;
|
||||
}
|
||||
|
||||
#endif // #if DEVICE_SERIAL_ASYNCH
|
||||
|
||||
bool serial_can_deep_sleep(void)
|
||||
{
|
||||
bool sleep_allowed = 1;
|
||||
|
|
Loading…
Reference in New Issue