summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fw/fe310/eos/spi_dev.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/fw/fe310/eos/spi_dev.c b/fw/fe310/eos/spi_dev.c
index d279faf..4713826 100644
--- a/fw/fe310/eos/spi_dev.c
+++ b/fw/fe310/eos/spi_dev.c
@@ -38,9 +38,13 @@ void eos_spi_dev_init(void) {
int eos_spi_select(unsigned char dev) {
if (dev == EOS_SPI_DEV_NET) return EOS_ERR;
- if (spi_dev != EOS_SPI_DEV_NET) return EOS_ERR;
+ if (spi_lock) return EOS_ERR_BUSY;
- eos_net_stop();
+ if (spi_dev == EOS_SPI_DEV_NET) {
+ eos_net_stop();
+ } else {
+ eos_spi_stop();
+ }
spi_dev = dev;
eos_spi_start(spi_div[dev], spi_cfg[dev].csid, spi_cfg[dev].cspin, spi_cfg[dev].evt);
@@ -49,8 +53,8 @@ int eos_spi_select(unsigned char dev) {
}
int eos_spi_deselect(void) {
- if (spi_lock) return EOS_ERR_BUSY;
if (spi_dev == EOS_SPI_DEV_NET) return EOS_ERR;
+ if (spi_lock) return EOS_ERR_BUSY;
eos_spi_stop();