diff options
| author | Bernard Xiong <[email protected]> | 2019-03-14 20:23:36 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-03-14 20:23:36 +0800 |
| commit | 656d20362b4a7a891171d3d444641aadda6b1a21 (patch) | |
| tree | a8d07d0e0de5111927dfa9ed7916188f7454aeea /bsp/stm32 | |
| parent | 38ffaf806c6e00042918631671372d00c10ee7e3 (diff) | |
| parent | bb97c76b5937864736d7fdb029bc0731c8cabf68 (diff) | |
Merge pull request #2449 from qgyhd1234/checksum
[components][lwip]添加 LWIP 硬件校验和选项,修改 STM32 系列和 rt1052 系列以太网驱动,支持硬件校验和
Diffstat (limited to 'bsp/stm32')
| -rw-r--r-- | bsp/stm32/libraries/HAL_Drivers/drv_eth.c | 39 |
1 files changed, 6 insertions, 33 deletions
diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_eth.c b/bsp/stm32/libraries/HAL_Drivers/drv_eth.c index 315c1b9890..493f4190ad 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_eth.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_eth.c @@ -44,10 +44,8 @@ struct rt_stm32_eth static ETH_DMADescTypeDef *DMARxDscrTab, *DMATxDscrTab; static rt_uint8_t *Rx_Buff, *Tx_Buff; -static rt_bool_t tx_is_waiting = RT_FALSE; static ETH_HandleTypeDef EthHandle; static struct rt_stm32_eth stm32_eth_device; -static struct rt_semaphore tx_wait; #if defined(ETH_RX_DUMP) || defined(ETH_TX_DUMP) #define __is_print(ch) ((unsigned int)((ch) - ' ') < 127u - ' ') @@ -91,8 +89,12 @@ static rt_err_t rt_stm32_eth_init(rt_device_t dev) EthHandle.Init.DuplexMode = ETH_MODE_FULLDUPLEX; EthHandle.Init.MediaInterface = ETH_MEDIA_INTERFACE_RMII; EthHandle.Init.RxMode = ETH_RXINTERRUPT_MODE; +#ifdef RT_LWIP_USING_HW_CHECKSUM + EthHandle.Init.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE; +#else EthHandle.Init.ChecksumMode = ETH_CHECKSUM_BY_SOFTWARE; - +#endif + HAL_ETH_DeInit(&EthHandle); /* configure ethernet peripheral (GPIOs, clocks, MAC, DMA) */ @@ -190,29 +192,13 @@ rt_err_t rt_stm32_eth_tx(rt_device_t dev, struct pbuf *p) DmaTxDesc = EthHandle.TxDesc; bufferoffset = 0; - /* Check if the descriptor is owned by the ETHERNET DMA (when set) or CPU (when reset) */ - while ((DmaTxDesc->Status & ETH_DMATXDESC_OWN) != (uint32_t)RESET) - { - rt_err_t result; - rt_uint32_t level; - - level = rt_hw_interrupt_disable(); - tx_is_waiting = RT_TRUE; - rt_hw_interrupt_enable(level); - - /* it's own bit set, wait it */ - result = rt_sem_take(&tx_wait, RT_WAITING_FOREVER); - if (result == RT_EOK) break; - if (result == -RT_ERROR) return -RT_ERROR; - } - /* copy frame from pbufs to driver buffers */ for (q = p; q != NULL; q = q->next) { /* Is this buffer available? If not, goto error */ if ((DmaTxDesc->Status & ETH_DMATXDESC_OWN) != (uint32_t)RESET) { - LOG_E("buffer not valid"); + LOG_D("buffer not valid"); ret = ERR_USE; goto error; } @@ -391,15 +377,6 @@ void ETH_IRQHandler(void) rt_interrupt_leave(); } -void HAL_ETH_TxCpltCallback(ETH_HandleTypeDef *heth) -{ - if (tx_is_waiting == RT_TRUE) - { - tx_is_waiting = RT_FALSE; - rt_sem_release(&tx_wait); - } -} - void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth) { rt_err_t result; @@ -635,10 +612,6 @@ static int rt_hw_stm32_eth_init(void) stm32_eth_device.parent.eth_rx = rt_stm32_eth_rx; stm32_eth_device.parent.eth_tx = rt_stm32_eth_tx; - /* init tx semaphore */ - rt_sem_init(&tx_wait, "tx_wait", 0, RT_IPC_FLAG_FIFO); - LOG_D("initialize tx wait semaphore"); - /* register eth device */ state = eth_device_init(&(stm32_eth_device.parent), "e0"); if (RT_EOK == state) |
