@@ -44,10 +44,8 @@ struct rt_stm32_eth
4444
4545static ETH_DMADescTypeDef * DMARxDscrTab , * DMATxDscrTab ;
4646static rt_uint8_t * Rx_Buff , * Tx_Buff ;
47- static rt_bool_t tx_is_waiting = RT_FALSE ;
4847static ETH_HandleTypeDef EthHandle ;
4948static struct rt_stm32_eth stm32_eth_device ;
50- static struct rt_semaphore tx_wait ;
5149
5250#if defined(ETH_RX_DUMP ) || defined(ETH_TX_DUMP )
5351#define __is_print (ch ) ((unsigned int)((ch) - ' ') < 127u - ' ')
@@ -91,8 +89,12 @@ static rt_err_t rt_stm32_eth_init(rt_device_t dev)
9189 EthHandle .Init .DuplexMode = ETH_MODE_FULLDUPLEX ;
9290 EthHandle .Init .MediaInterface = ETH_MEDIA_INTERFACE_RMII ;
9391 EthHandle .Init .RxMode = ETH_RXINTERRUPT_MODE ;
92+ #ifdef RT_LWIP_USING_HW_CHECKSUM
93+ EthHandle .Init .ChecksumMode = ETH_CHECKSUM_BY_HARDWARE ;
94+ #else
9495 EthHandle .Init .ChecksumMode = ETH_CHECKSUM_BY_SOFTWARE ;
95-
96+ #endif
97+
9698 HAL_ETH_DeInit (& EthHandle );
9799
98100 /* 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)
190192 DmaTxDesc = EthHandle .TxDesc ;
191193 bufferoffset = 0 ;
192194
193- /* Check if the descriptor is owned by the ETHERNET DMA (when set) or CPU (when reset) */
194- while ((DmaTxDesc -> Status & ETH_DMATXDESC_OWN ) != (uint32_t )RESET )
195- {
196- rt_err_t result ;
197- rt_uint32_t level ;
198-
199- level = rt_hw_interrupt_disable ();
200- tx_is_waiting = RT_TRUE ;
201- rt_hw_interrupt_enable (level );
202-
203- /* it's own bit set, wait it */
204- result = rt_sem_take (& tx_wait , RT_WAITING_FOREVER );
205- if (result == RT_EOK ) break ;
206- if (result == - RT_ERROR ) return - RT_ERROR ;
207- }
208-
209195 /* copy frame from pbufs to driver buffers */
210196 for (q = p ; q != NULL ; q = q -> next )
211197 {
212198 /* Is this buffer available? If not, goto error */
213199 if ((DmaTxDesc -> Status & ETH_DMATXDESC_OWN ) != (uint32_t )RESET )
214200 {
215- LOG_E ("buffer not valid" );
201+ LOG_D ("buffer not valid" );
216202 ret = ERR_USE ;
217203 goto error ;
218204 }
@@ -391,15 +377,6 @@ void ETH_IRQHandler(void)
391377 rt_interrupt_leave ();
392378}
393379
394- void HAL_ETH_TxCpltCallback (ETH_HandleTypeDef * heth )
395- {
396- if (tx_is_waiting == RT_TRUE )
397- {
398- tx_is_waiting = RT_FALSE ;
399- rt_sem_release (& tx_wait );
400- }
401- }
402-
403380void HAL_ETH_RxCpltCallback (ETH_HandleTypeDef * heth )
404381{
405382 rt_err_t result ;
@@ -635,10 +612,6 @@ static int rt_hw_stm32_eth_init(void)
635612 stm32_eth_device .parent .eth_rx = rt_stm32_eth_rx ;
636613 stm32_eth_device .parent .eth_tx = rt_stm32_eth_tx ;
637614
638- /* init tx semaphore */
639- rt_sem_init (& tx_wait , "tx_wait" , 0 , RT_IPC_FLAG_FIFO );
640- LOG_D ("initialize tx wait semaphore" );
641-
642615 /* register eth device */
643616 state = eth_device_init (& (stm32_eth_device .parent ), "e0" );
644617 if (RT_EOK == state )
0 commit comments