You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by we...@apache.org on 2016/09/07 05:41:49 UTC

incubator-mynewt-core git commit: MYNEWT-3: HAL SPI

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/sterly_refactor aab7b2a25 -> fdd134d75


MYNEWT-3: HAL SPI

Fix bug where transfer flag was not being set for non-blocking transfers.
Check that a transfer was actually in progress in ISR.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/fdd134d7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/fdd134d7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/fdd134d7

Branch: refs/heads/sterly_refactor
Commit: fdd134d7525ac448af567ad3ebb25d1c2b057f04
Parents: aab7b2a
Author: William San Filippo <wi...@runtime.io>
Authored: Tue Sep 6 22:40:47 2016 -0700
Committer: William San Filippo <wi...@runtime.io>
Committed: Tue Sep 6 22:40:47 2016 -0700

----------------------------------------------------------------------
 hw/mcu/nordic/nrf51xxx/src/hal_spi.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fdd134d7/hw/mcu/nordic/nrf51xxx/src/hal_spi.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf51xxx/src/hal_spi.c b/hw/mcu/nordic/nrf51xxx/src/hal_spi.c
index 6ac5083..010bd8b 100644
--- a/hw/mcu/nordic/nrf51xxx/src/hal_spi.c
+++ b/hw/mcu/nordic/nrf51xxx/src/hal_spi.c
@@ -120,11 +120,14 @@ nrf51_irqm_handler(struct nrf51_hal_spi *spi)
 {
     NRF_SPI_Type *p_spi;
 
-    /* XXX: what if not in a transfer? */
-
     p_spi = (NRF_SPI_Type *)spi->nhs_spi.spim.p_registers;
     if (nrf_spi_event_check(p_spi, NRF_SPI_EVENT_READY)) {
         nrf_spi_event_clear(p_spi, NRF_SPI_EVENT_READY);
+
+        if (spi->spi_xfr_flag == 0) {
+            return;
+        }
+
         if (spi->nhs_rxbuf) {
             spi->nhs_rxbuf[spi->nhs_rxd_bytes] = nrf_spi_rxd_get(p_spi);
         }
@@ -841,6 +844,7 @@ hal_spi_txrx(int spi_num, void *txbuf, void *rxbuf, int len)
                 rc = -1;
                 goto err;
             }
+            spi->spi_xfr_flag = 1;
 
             spi->nhs_buflen = (uint16_t)len;
             spi->nhs_txbuf = txbuf;