Skip to content

Commit

Permalink
fixup! cpu/sam0_common: eth: port to new netdev API
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed May 15, 2024
1 parent a8674d1 commit 7429778
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 9 additions & 2 deletions cpu/sam0_common/periph/eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ int sam0_eth_send(const struct iolist *iolist)
tx_curr->status |= DESC_TX_STATUS_WRAP;
tx_idx = 0;
}
__DSB();
__DMB();
/* Start transmission */
GMAC->NCR.reg |= GMAC_NCR_TSTART;
/* Set the next buffer */
Expand All @@ -258,6 +258,12 @@ int sam0_eth_send(const struct iolist *iolist)
return len;
}

unsigned _sam0_eth_get_last_len(void)
{
unsigned idx = tx_idx ? tx_idx - 1 : ETH_TX_BUFFER_COUNT - 1;
return tx_desc[idx].status & DESC_TX_STATUS_LEN_MASK;
}

static int _try_receive(char* data, unsigned max_len, int block)
{
(void)block;
Expand Down Expand Up @@ -386,7 +392,8 @@ int sam0_eth_init(void)
GMAC->RSR.reg = GMAC_RSR_HNO | GMAC_RSR_RXOVR | GMAC_RSR_REC | GMAC_RSR_BNA;
GMAC->TSR.reg = 0xFFFF;
/* Enable needed interrupts */
GMAC->IER.reg = GMAC_IER_RCOMP | GMAC_IER_TCOMP;
GMAC->IER.reg = GMAC_IER_RCOMP
| GMAC_IER_TCOMP | GMAC_IER_TFC | GMAC_IER_RLEX;

GMAC->NCFGR.reg = GMAC_NCFGR_MTIHEN
| GMAC_NCFGR_RXCOEN | GMAC_NCFGR_MAXFS | GMAC_NCFGR_CAF
Expand Down
7 changes: 4 additions & 3 deletions cpu/sam0_common/sam0_eth/eth-netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,13 @@ static int _sam0_eth_confirm_send(netdev_t *netdev, void *info)
return -EBUSY;
}

/* Transmit Frame Corruption, Collision Occurred, Transmit Underrun */
if (tsr & (GMAC_TSR_TFC | GMAC_TSR_COL | GMAC_TSR_UND)) {
/* Transmit Frame Corruption, Collision Occurred */
if (tsr & (GMAC_TSR_TFC | GMAC_TSR_COL)) {
return -EIO;
}

return 1;
extern unsigned _sam0_eth_get_last_len(void);
return _sam0_eth_get_last_len();
}

static int _sam0_eth_get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len)
Expand Down

0 comments on commit 7429778

Please sign in to comment.