From c067fd2801a5f2e3ec3c9983736b4069cbfd770c Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Tue, 2 Apr 2024 22:57:31 +0200 Subject: [PATCH] sam0_eth: wait until the current tx buffer is no longer in use --- cpu/sam0_common/periph/eth.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cpu/sam0_common/periph/eth.c b/cpu/sam0_common/periph/eth.c index d1eb9dc6154b..3d49a2108e5c 100644 --- a/cpu/sam0_common/periph/eth.c +++ b/cpu/sam0_common/periph/eth.c @@ -185,6 +185,7 @@ static void _init_desc_buf(void) /* Initialize TX buffer descriptors */ for (i=0; i < ETH_TX_BUFFER_COUNT; i++) { tx_desc[i].address = (uint32_t) tx_buf[i]; + tx_desc[i].status = DESC_TX_STATUS_USED; } /* Set WRAP flag to indicate last buffer */ tx_desc[i-1].status |= DESC_TX_STATUS_WRAP; @@ -225,6 +226,11 @@ int sam0_eth_send(const struct iolist *iolist) return -ENOTSUP; } + /* wait until the current buffer is no longer in use */ + while (!(tx_curr->status & DESC_TX_STATUS_USED)) { + thread_yield(); + } + /* load packet data into TX buffer */ for (const iolist_t *iol = iolist; iol; iol = iol->iol_next) { if (tx_len + iol->iol_len > ETHERNET_MAX_LEN) {