From 6e590ae189f245bf0b567ddcc2f16a34088d0805 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Wed, 27 Nov 2019 05:11:57 +0100 Subject: spi/net integration bugfix --- code/fe310/eos/net.c | 29 +++++++++++++++++------------ code/fe310/eos/net_def.h | 1 + code/fe310/eos/spi.c | 21 ++++++++++----------- code/fe310/eos/spi.h | 1 + 4 files changed, 29 insertions(+), 23 deletions(-) (limited to 'code/fe310/eos') diff --git a/code/fe310/eos/net.c b/code/fe310/eos/net.c index b6f5722..1b9e34a 100644 --- a/code/fe310/eos/net.c +++ b/code/fe310/eos/net.c @@ -72,7 +72,7 @@ static unsigned char *net_bufq_pop(void) { static void net_xchg_reset(void) { net_state_flags &= ~NET_STATE_FLAG_CTS; - net_state_flags |= NET_STATE_FLAG_RST; + net_state_flags |= (NET_STATE_FLAG_RST | NET_STATE_FLAG_XCHG); // before starting a transaction, set SPI peripheral to desired mode SPI1_REG(SPI_REG_CSMODE) = SPI_CSMODE_HOLD; @@ -85,7 +85,7 @@ static void net_xchg_reset(void) { static void net_xchg_start(unsigned char type, unsigned char *buffer, uint16_t len) { net_state_flags &= ~NET_STATE_FLAG_CTS; - net_state_flags |= NET_STATE_FLAG_INIT; + net_state_flags |= (NET_STATE_FLAG_INIT | NET_STATE_FLAG_XCHG); if (net_state_next_cnt && (net_state_next_buf == NULL)) type |= NET_MTYPE_FLAG_ONEW; if (type & NET_MTYPE_FLAG_ONEW) net_state_flags |= NET_STATE_FLAG_ONEW; @@ -183,6 +183,7 @@ void eos_net_xchg_done(void) { } else { net_bufq_push(_eos_spi_state_buf); } + net_state_flags &= ~NET_STATE_FLAG_XCHG; } static void net_handler_cts(void) { @@ -244,6 +245,13 @@ void eos_net_set_handler(unsigned char mtype, eos_evt_fptr_t handler, uint8_t fl void eos_net_init(void) { int i; + net_bufq_init(); + eos_msgq_init(&net_send_q, net_sndq_array, NET_SIZE_BUFQ); + for (i=0; i +#include "event.h" #define EOS_SPI_DEV_NET 0 #define EOS_SPI_DEV_DISP 1 -- cgit v1.2.3