You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/09/25 06:37:28 UTC

[GitHub] kasjer closed pull request #1420: fe310: Fix SPI blocking read

kasjer closed pull request #1420: fe310: Fix SPI blocking read
URL: https://github.com/apache/mynewt-core/pull/1420
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/hw/mcu/sifive/fe310/include/mcu/fe310_hal.h b/hw/mcu/sifive/fe310/include/mcu/fe310_hal.h
index ac0fd2b939..297c992527 100644
--- a/hw/mcu/sifive/fe310/include/mcu/fe310_hal.h
+++ b/hw/mcu/sifive/fe310/include/mcu/fe310_hal.h
@@ -51,6 +51,8 @@ void hal_uart_sys_clock_changed(void);
 
 void hal_uart_sys_clock_changed(void);
 
+#define FE310_SPI_FIFO_LENGHT 8
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/hw/mcu/sifive/fe310/src/hal_spi.c b/hw/mcu/sifive/fe310/src/hal_spi.c
index 7e1d7e0776..09f0fa65fc 100644
--- a/hw/mcu/sifive/fe310/src/hal_spi.c
+++ b/hw/mcu/sifive/fe310/src/hal_spi.c
@@ -359,15 +359,11 @@ hal_spi_txrx(int spi_num, void *txbuf, void *rxbuf, int len)
         rc = SYS_EINVAL;
         goto err;
     }
-    while (_REG32(spi->spi_base, SPI_REG_TXFIFO) & SPI_TXFIFO_FULL) {
-        if (_REG32(spi->spi_base, SPI_REG_RXFIFO)) {
-        }
-    }
     while (!(_REG32(spi->spi_base, SPI_REG_RXFIFO) & SPI_RXFIFO_EMPTY)) {
     }
 
     while (received < len) {
-        if (sent < len &&
+        if (sent < len && (sent - received) < FE310_SPI_FIFO_LENGHT &&
             !(_REG32(spi->spi_base, SPI_REG_TXFIFO) & SPI_TXFIFO_FULL)) {
             _REG32(spi->spi_base, SPI_REG_TXFIFO) = ((uint8_t *)txbuf)[sent++];
         }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services