From 58f41971b1e801ad2fbcea08e5152afa2b18ca73 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Mon, 28 Jul 2025 23:27:12 +0200 Subject: sys logging added; power management reimplemented; bugfixes; --- fw/fe310/eos/soc/spi.c | 119 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 77 insertions(+), 42 deletions(-) (limited to 'fw/fe310/eos/soc/spi.c') diff --git a/fw/fe310/eos/soc/spi.c b/fw/fe310/eos/soc/spi.c index 1806f50..64a057b 100644 --- a/fw/fe310/eos/soc/spi.c +++ b/fw/fe310/eos/soc/spi.c @@ -3,13 +3,16 @@ #include "encoding.h" #include "platform.h" +#include "board.h" #include "eos.h" +#include "log.h" #include "msgq.h" #include "interrupt.h" #include "event.h" -#include "board.h" +#include "dev/egpio.h" +#include "dev/egpio_priv.h" #include "spi.h" #include "spi_priv.h" @@ -21,15 +24,12 @@ #define SPI_FLAG_XCHG 0x10 -#define SPI_CSID_NONE 1 - #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) #define MAX(X, Y) (((X) > (Y)) ? (X) : (Y)) static uint8_t spi_cspin; static volatile uint8_t spi_state_flags; static unsigned char spi_evt; -static unsigned char spi_in_xchg; static uint32_t spi_state_len = 0; static uint32_t spi_state_idx_tx = 0; @@ -40,6 +40,7 @@ static eos_evt_handler_t evt_handler[EOS_SPI_MAX_EVT]; static void spi_handle_evt(unsigned char type, unsigned char *buffer, uint16_t len) { unsigned char idx = (type & ~EOS_EVT_MASK) - 1; + if (idx < EOS_SPI_MAX_EVT) { evt_handler[idx](type, buffer, len); } else { @@ -47,7 +48,7 @@ static void spi_handle_evt(unsigned char type, unsigned char *buffer, uint16_t l } } -int eos_spi_init(uint8_t wakeup_cause) { +int eos_spi_init(void) { int i; for (i=0; i