From 6a4c8a1f11f6a7bd57b0fd618f455bcdecbfe538 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Sun, 28 Feb 2021 18:38:37 +0100 Subject: net send will do selected spi dev pause/resume if more is set and netowk is not active --- fw/fe310/eos/spi_dev.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'fw/fe310/eos/spi_dev.c') diff --git a/fw/fe310/eos/spi_dev.c b/fw/fe310/eos/spi_dev.c index aed26bc..abb616d 100644 --- a/fw/fe310/eos/spi_dev.c +++ b/fw/fe310/eos/spi_dev.c @@ -4,6 +4,7 @@ #include "encoding.h" #include "platform.h" +#include "eos.h" #include "spi.h" #include "net.h" @@ -22,24 +23,41 @@ static uint16_t spi_dev_div[EOS_DEV_MAX_DEV]; -void eos_spi_dev_start(unsigned char dev) { - eos_net_stop(); +int eos_spi_dev_select(unsigned char dev) { + uint8_t spi_dev = eos_spi_dev(); + int rv = EOS_ERR; + + if (spi_dev) { + int rv; + + rv = eos_spi_stop(); + if (rv) return rv; + } else { + eos_net_stop(); + } switch (dev) { case EOS_DEV_DISP: - eos_spi_start(dev, spi_dev_div[dev-1], SPI_CSID_DISP, 0); + rv = eos_spi_start(dev, spi_dev_div[dev-1], SPI_CSID_DISP, 0); break; case EOS_DEV_CARD: - eos_spi_start(dev, spi_dev_div[dev-1], SPI_CSID_CARD, 0); + rv = eos_spi_start(dev, spi_dev_div[dev-1], SPI_CSID_CARD, 0); break; case EOS_DEV_CAM: - eos_spi_start(dev, spi_dev_div[dev-1], SPI_CSID_NONE, SPI_CSPIN_CAM); + rv = eos_spi_start(dev, spi_dev_div[dev-1], SPI_CSID_NONE, SPI_CSPIN_CAM); break; } + + return rv; } -void eos_spi_dev_stop(void) { - eos_spi_stop(); +int eos_spi_dev_deselect(void) { + int rv; + + rv = eos_spi_stop(); + if (rv) return rv; eos_net_start(); + + return EOS_OK; } void eos_spi_dev_init(void) { -- cgit v1.2.3