summaryrefslogtreecommitdiff
path: root/fw
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2021-05-10 16:53:58 +0200
committerUros Majstorovic <majstor@majstor.org>2021-05-10 16:53:58 +0200
commit2aaa54722c78e4739026d8ed608e8c7ff162a38c (patch)
tree477209377e05ee0e2d670138f6e6ab4a8cf54816 /fw
parent91ff7f239fc60052f141d8ca98751c610b6b18db (diff)
spi_dev: deselect not mandatory prior to select
Diffstat (limited to 'fw')
-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();