diff options
Diffstat (limited to 'fw/fe310/eos/soc/spi.c')
-rw-r--r-- | fw/fe310/eos/soc/spi.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/fw/fe310/eos/soc/spi.c b/fw/fe310/eos/soc/spi.c index 351c9c8..1806f50 100644 --- a/fw/fe310/eos/soc/spi.c +++ b/fw/fe310/eos/soc/spi.c @@ -188,7 +188,9 @@ void eos_spi_handle_xchg(void) { void eos_spi_cs_set(void) { /* cs low */ if (SPI1_REG(SPI_REG_CSMODE) == SPI_CSMODE_OFF) { + clear_csr(mstatus, MSTATUS_MIE); GPIO_REG(GPIO_OUTPUT_VAL) &= ~(1 << spi_cspin); + set_csr(mstatus, MSTATUS_MIE); } else { SPI1_REG(SPI_REG_CSMODE) = SPI_CSMODE_HOLD; } @@ -197,7 +199,9 @@ void eos_spi_cs_set(void) { void eos_spi_cs_clear(void) { /* cs high */ if (SPI1_REG(SPI_REG_CSMODE) == SPI_CSMODE_OFF) { + clear_csr(mstatus, MSTATUS_MIE); GPIO_REG(GPIO_OUTPUT_VAL) |= (1 << spi_cspin); + set_csr(mstatus, MSTATUS_MIE); } else { SPI1_REG(SPI_REG_CSMODE) = SPI_CSMODE_AUTO; } @@ -363,14 +367,4 @@ void eos_spi_flush(void) { while (!(SPI1_REG(SPI_REG_IP) & SPI_IP_TXWM)); while (!(SPI1_REG(SPI_REG_RXFIFO) & SPI_RXFIFO_EMPTY)); } - - /* - volatile uint32_t x = 0; - - while (!x) { - if (SPI1_REG(SPI_REG_IP) & SPI_IP_TXWM) { - x = SPI1_REG(SPI_REG_RXFIFO) & SPI_RXFIFO_EMPTY; - } - } - */ } |