@@ -272,7 +272,7 @@ rt_err_t rt_gd32_eth_tx(rt_device_t dev, struct pbuf *p)
272272
273273 uint8_t * buffer = (uint8_t * )(dma_txdesc -> buffer1_addr );
274274
275- /* copy frame from pbufs to driver buffers */
275+ /* copy frame from pbufs to driver buffers */
276276 for (q = p ; q != NULL ; q = q -> next )
277277 {
278278 /* Is this buffer available? If not, goto error */
@@ -282,37 +282,8 @@ rt_err_t rt_gd32_eth_tx(rt_device_t dev, struct pbuf *p)
282282 goto _error ;
283283 }
284284
285- /* Get bytes in current lwIP buffer */
286- byteslefttocopy = q -> len ;
287- payloadoffset = 0 ;
288-
289- /* Check if the length of data to copy is bigger than Tx buffer size */
290- while ((byteslefttocopy + bufferoffset ) > ENET_TXBUF_SIZE )
291- {
292- /* Copy data to Tx buffer*/
293- SMEMCPY ((uint8_t * )((uint8_t * )buffer + bufferoffset ), (uint8_t * )((uint8_t * )q -> payload + payloadoffset ), (ENET_TXBUF_SIZE - bufferoffset ));
294-
295- /* Point to next descriptor */
296- dma_txdesc = (enet_descriptors_struct * )(dma_txdesc -> buffer2_next_desc_addr );
297-
298- /* Check if the buffer is available */
299- if ((dma_txdesc -> status & ENET_TDES0_DAV ) != (uint32_t )RESET )
300- {
301- ret = RT_EOK ;
302- goto _error ;
303- }
304-
305- buffer = (uint8_t * )(dma_txdesc -> buffer1_addr );
306-
307- byteslefttocopy = byteslefttocopy - (ENET_TXBUF_SIZE - bufferoffset );
308- payloadoffset = payloadoffset + (ENET_TXBUF_SIZE - bufferoffset );
309- framelength = framelength + (ENET_TXBUF_SIZE - bufferoffset );
310- bufferoffset = 0 ;
311- }
312-
313- /* Copy the remaining bytes */
314- SMEMCPY ((uint8_t * )((uint8_t * )buffer + bufferoffset ), (uint8_t * )((uint8_t * )q -> payload + payloadoffset ), byteslefttocopy );
315- framelength = framelength + byteslefttocopy ;
285+ rt_memcpy ((uint8_t * )& buffer [framelength ], q -> payload , q -> len );
286+ framelength = framelength + q -> len ;
316287 }
317288
318289 /* transmit descriptors to give to DMA */
0 commit comments