This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new 61844a0db mcu/nordic: Set flags before running SPI callback
61844a0db is described below
commit 61844a0dbd4fe366d6c5726e6c5d754969cf31e6
Author: Uks2 <[email protected]>
AuthorDate: Mon Jan 29 13:58:00 2024 +0000
mcu/nordic: Set flags before running SPI callback
When a non-blocking SPI transfer has finished, our `spi->spi_xfr_flag`
and the hardware interrupt flag are now reset before the
`spi->txrx_cb_func` is run. This allows the callback to start a new SPI
transfer.
---
hw/mcu/nordic/nrf51xxx/src/hal_spi.c | 4 ++--
hw/mcu/nordic/nrf52xxx/src/hal_spi.c | 5 ++---
hw/mcu/nordic/nrf5340/src/hal_spi.c | 5 ++---
hw/mcu/nordic/nrf5340_net/src/hal_spi.c | 5 ++---
hw/mcu/nordic/nrf91xx/src/hal_spi.c | 5 ++---
5 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/hw/mcu/nordic/nrf51xxx/src/hal_spi.c
b/hw/mcu/nordic/nrf51xxx/src/hal_spi.c
index 98f9211a2..2ad303a73 100644
--- a/hw/mcu/nordic/nrf51xxx/src/hal_spi.c
+++ b/hw/mcu/nordic/nrf51xxx/src/hal_spi.c
@@ -129,11 +129,11 @@ nrf51_irqm_handler(struct nrf51_hal_spi *spi)
}
++spi->nhs_rxd_bytes;
if (spi->nhs_rxd_bytes == spi->nhs_buflen) {
+ spi->spi_xfr_flag = 0;
+ spim->INTENCLR = SPI_INTENCLR_READY_Msk;
if (spi->txrx_cb_func) {
spi->txrx_cb_func(spi->txrx_cb_arg, spi->nhs_buflen);
}
- spi->spi_xfr_flag = 0;
- spim->INTENCLR = SPI_INTENCLR_READY_Msk;
}
if (spi->nhs_txd_bytes != spi->nhs_buflen) {
spim->TXD = spi->nhs_txbuf[spi->nhs_txd_bytes];
diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_spi.c
b/hw/mcu/nordic/nrf52xxx/src/hal_spi.c
index a66ad8835..b8f3ebdac 100644
--- a/hw/mcu/nordic/nrf52xxx/src/hal_spi.c
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_spi.c
@@ -212,12 +212,11 @@ nrf52_irqm_handler(struct nrf52_hal_spi *spi)
}
spim->TASKS_START = 1;
} else {
+ spi->spi_xfr_flag = 0;
+ spim->INTENCLR = SPIM_INTENSET_END_Msk;
if (spi->txrx_cb_func) {
spi->txrx_cb_func(spi->txrx_cb_arg, spi->nhs_buflen);
-
}
- spi->spi_xfr_flag = 0;
- spim->INTENCLR = SPIM_INTENSET_END_Msk;
}
}
}
diff --git a/hw/mcu/nordic/nrf5340/src/hal_spi.c
b/hw/mcu/nordic/nrf5340/src/hal_spi.c
index aaaa38845..caeab72e9 100644
--- a/hw/mcu/nordic/nrf5340/src/hal_spi.c
+++ b/hw/mcu/nordic/nrf5340/src/hal_spi.c
@@ -170,12 +170,11 @@ nrf5340_irqm_handler(struct nrf5340_hal_spi *spi)
}
spim->TASKS_START = 1;
} else {
+ spi->spi_xfr_flag = 0;
+ spim->INTENCLR = SPIM_INTENSET_END_Msk;
if (spi->txrx_cb_func) {
spi->txrx_cb_func(spi->txrx_cb_arg, spi->nhs_buflen);
-
}
- spi->spi_xfr_flag = 0;
- spim->INTENCLR = SPIM_INTENSET_END_Msk;
}
}
}
diff --git a/hw/mcu/nordic/nrf5340_net/src/hal_spi.c
b/hw/mcu/nordic/nrf5340_net/src/hal_spi.c
index a9578e361..2f9cfe3c9 100644
--- a/hw/mcu/nordic/nrf5340_net/src/hal_spi.c
+++ b/hw/mcu/nordic/nrf5340_net/src/hal_spi.c
@@ -121,12 +121,11 @@ nrf5340_net_spi0_irq_handler(void)
}
NRF_SPIM0_NS->TASKS_START = 1;
} else {
+ spi->spi_xfr_flag = 0;
+ NRF_SPIM0_NS->INTENCLR = SPIM_INTENSET_END_Msk;
if (spi->txrx_cb_func) {
spi->txrx_cb_func(spi->txrx_cb_arg, spi->nhs_buflen);
-
}
- spi->spi_xfr_flag = 0;
- NRF_SPIM0_NS->INTENCLR = SPIM_INTENSET_END_Msk;
}
}
}
diff --git a/hw/mcu/nordic/nrf91xx/src/hal_spi.c
b/hw/mcu/nordic/nrf91xx/src/hal_spi.c
index 368f7cf2f..a68e4181d 100644
--- a/hw/mcu/nordic/nrf91xx/src/hal_spi.c
+++ b/hw/mcu/nordic/nrf91xx/src/hal_spi.c
@@ -170,12 +170,11 @@ nrf91_irqm_handler(struct nrf91_hal_spi *spi)
}
spim->TASKS_START = 1;
} else {
+ spi->spi_xfr_flag = 0;
+ spim->INTENCLR = SPIM_INTENSET_END_Msk;
if (spi->txrx_cb_func) {
spi->txrx_cb_func(spi->txrx_cb_arg, spi->buflen);
-
}
- spi->spi_xfr_flag = 0;
- spim->INTENCLR = SPIM_INTENSET_END_Msk;
}
}
}