1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/stm32/periph/eth: update to new API

This commit is contained in:
Marian Buschsieweke 2021-01-14 22:17:30 +01:00 committed by Marian Buschsieweke
parent 6ac1bcad7e
commit 14795d4de0
No known key found for this signature in database
GPG Key ID: 77AA882EC78084E6
3 changed files with 17 additions and 13 deletions

View File

@ -49,7 +49,7 @@ ifneq (,$(filter stm32_eth,$(USEMODULE)))
FEATURES_REQUIRED += periph_eth
USEMODULE += iolist
USEMODULE += netdev_eth
USEMODULE += netdev_legacy_api
USEMODULE += netdev_new_api
USEMODULE += ztimer
USEMODULE += ztimer_msec

View File

@ -142,9 +142,6 @@ static ztimer_t _link_status_timer;
#endif
/** @} */
/* Synchronization between IRQ and thread context */
mutex_t stm32_eth_tx_completed = MUTEX_INIT_LOCKED;
/* Descriptors */
static edma_desc_t rx_desc[ETH_RX_DESCRIPTOR_COUNT];
static edma_desc_t tx_desc[ETH_TX_DESCRIPTOR_COUNT];
@ -586,20 +583,26 @@ static int stm32_eth_send(netdev_t *netdev, const struct iolist *iolist)
}
/* start TX */
ETH->DMATPDR = 0;
/* await completion */
if (IS_ACTIVE(ENABLE_DEBUG_VERBOSE)) {
DEBUG("[stm32_eth] Started to send %u B via DMA\n", bytes_to_send);
}
mutex_lock(&stm32_eth_tx_completed);
return 0;
}
static int stm32_eth_confirm_send(netdev_t *netdev, void *info)
{
(void)info;
(void)netdev;
if (IS_USED(MODULE_STM32_ETH_TRACING)) {
gpio_ll_clear(GPIO_PORT(STM32_ETH_TRACING_TX_PORT_NUM),
(1U << STM32_ETH_TRACING_TX_PIN_NUM));
}
if (IS_ACTIVE(ENABLE_DEBUG_VERBOSE)) {
DEBUG("[stm32_eth] TX completed\n");
}
DEBUG("[stm32_eth] TX completed\n");
/* Error check */
_debug_tx_descriptor_info(__LINE__);
int tx_bytes = 0;
int error = 0;
while (1) {
uint32_t status = tx_curr->status;
@ -624,6 +627,7 @@ static int stm32_eth_send(netdev_t *netdev, const struct iolist *iolist)
_reset_eth_dma();
}
tx_curr = tx_curr->desc_next;
tx_bytes += tx_curr->control;
if (status & TX_DESC_STAT_LS) {
break;
}
@ -631,11 +635,10 @@ static int stm32_eth_send(netdev_t *netdev, const struct iolist *iolist)
_debug_tx_descriptor_info(__LINE__);
netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE);
if (error) {
return error;
}
return (int)bytes_to_send;
return tx_bytes;
}
static int get_rx_frame_size(void)
@ -811,6 +814,7 @@ static void stm32_eth_isr(netdev_t *netdev)
static const netdev_driver_t netdev_driver_stm32f4eth = {
.send = stm32_eth_send,
.confirm_send = stm32_eth_confirm_send,
.recv = stm32_eth_recv,
.init = stm32_eth_init,
.isr = stm32_eth_isr,

View File

@ -122,14 +122,14 @@ void isr_eth(void)
if (IS_USED(MODULE_STM32_ETH)) {
extern netdev_t *stm32_eth_netdev;
extern mutex_t stm32_eth_tx_completed;
unsigned tmp = ETH->DMASR;
ETH->DMASR = ETH_DMASR_NIS | ETH_DMASR_TS | ETH_DMASR_RS;
DEBUG("[periph_eth_common] DMASR = 0x%x\n", tmp);
if ((tmp & ETH_DMASR_TS)) {
DEBUG("isr_eth: TX completed\n");
mutex_unlock(&stm32_eth_tx_completed);
stm32_eth_netdev->event_callback(stm32_eth_netdev,
NETDEV_EVENT_TX_COMPLETE);
}
if ((tmp & ETH_DMASR_RS)) {