Skip to content

Commit

Permalink
sam0_eth: wait until the current tx buffer is no longer in use
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Apr 2, 2024
1 parent 3c07ebc commit c067fd2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cpu/sam0_common/periph/eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit c067fd2

Please sign in to comment.