From 66e53b7e54878e2161f5c0dab6f90aebd9a1d97a Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Thu, 8 Apr 2021 02:27:15 +0200 Subject: added board.h --- fw/fe310/eos/spi.c | 66 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 16 deletions(-) (limited to 'fw/fe310/eos/spi.c') diff --git a/fw/fe310/eos/spi.c b/fw/fe310/eos/spi.c index 29970bd..932c5f1 100644 --- a/fw/fe310/eos/spi.c +++ b/fw/fe310/eos/spi.c @@ -9,18 +9,19 @@ #include "interrupt.h" #include "event.h" +#include "board.h" + #include "net.h" #include "spi.h" -#include "spi_def.h" -#include "irq_def.h" +#include "spi_priv.h" #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) #define MAX(X, Y) (((X) > (Y)) ? (X) : (Y)) -#define SPI_IOF_MASK (((uint32_t)1 << IOF_SPI1_SCK) | ((uint32_t)1 << IOF_SPI1_MOSI) | ((uint32_t)1 << IOF_SPI1_MISO)) | ((uint32_t)1 << IOF_SPI1_SS0) | ((uint32_t)1 << IOF_SPI1_SS2) | ((uint32_t)1 << IOF_SPI1_SS3) static uint8_t spi_dev; -static uint8_t spi_dev_cs_pin; +static uint8_t spi_cspin; static uint8_t spi_lock; +static uint16_t spi_div[EOS_SPI_MAX_DEV]; static volatile uint8_t spi_state_flags; static unsigned char spi_in_xchg; @@ -60,28 +61,45 @@ void eos_spi_init(void) { // There is no way here to change the CS polarity. // SPI1_REG(SPI_REG_CSDEF) = 0xFFFF; + + for (i=0; i