From 46b08fc235f3f068034355970697acc0956e5c99 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Wed, 7 Jan 2026 22:58:33 +0100 Subject: introduced EOSMessage struct for SPI and Event queue messages; added APP <-> FE310 bridge SPI messages; LCD/touch panel driver for app module; save relevant state to AON module before sleep; --- fw/fe310/eos/soc/spi.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 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 64a057b..a337924 100644 --- a/fw/fe310/eos/soc/spi.c +++ b/fw/fe310/eos/soc/spi.c @@ -7,7 +7,6 @@ #include "eos.h" #include "log.h" -#include "msgq.h" #include "interrupt.h" #include "event.h" @@ -35,24 +34,25 @@ static uint32_t spi_state_len = 0; static uint32_t spi_state_idx_tx = 0; static uint32_t spi_state_idx_rx = 0; static unsigned char *spi_state_buf = NULL; +static uint16_t spi_state_buf_sz = 0; -static eos_evt_handler_t evt_handler[EOS_SPI_MAX_EVT]; +static eos_evt_handler_t spi_handler[EOS_SPI_MAX_ETYPE]; -static void spi_handle_evt(unsigned char type, unsigned char *buffer, uint16_t len) { - unsigned char idx = (type & ~EOS_EVT_MASK) - 1; +static void spi_handle_evt(unsigned char type, EOSMessage *msg, uint16_t len) { + unsigned char idx = type & ~EOS_EVT_MASK; - if (idx < EOS_SPI_MAX_EVT) { - evt_handler[idx](type, buffer, len); + if (idx && (idx <= EOS_SPI_MAX_ETYPE) && spi_handler[idx - 1]) { + spi_handler[idx - 1](type & ~EOS_EVT_MASK, msg, len); } else { - eos_evtq_bad_handler(type, buffer, len); + eos_evtq_bad_handler(type, msg, len); } } int eos_spi_init(void) { int i; - for (i=0; ibuffer, msg->size, len, flags); eos_spi_set_cs(); SPI1_REG(SPI_REG_TXCTRL) = SPI_TXWM(SPI_SIZE_WM); @@ -184,9 +185,12 @@ void eos_spi_handle_xchg(void) { spi_state_flags &= (~SPI_FLAG_XCHG & 0xF0); if (spi_evt) { + EOSMessage msg; int rv; - rv = eos_evtq_push_isr(EOS_EVT_SPI | spi_evt, spi_state_buf, spi_state_len); + msg.buffer = spi_state_buf; + msg.size = spi_state_buf_sz; + rv = eos_evtq_push_isr(EOS_EVT_SPI | spi_evt, &msg, spi_state_len); if (rv) EOS_LOG(EOS_LOG_ERR, "SPI XCHG EVTQ PUSH ERR:%d\n", rv); } } else { -- cgit v1.2.3