MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_ecm_eth_rx

Function rt_ecm_eth_rx

components/legacy/usb/usbdevice/class/ecm.c:368–405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

366#endif
367
368struct pbuf *rt_ecm_eth_rx(rt_device_t dev)
369{
370 struct pbuf* p = RT_NULL;
371 rt_uint32_t offset = 0;
372 rt_ecm_eth_t ecm_eth_dev = (rt_ecm_eth_t)dev;
373 if(ecm_eth_dev->rx_size != 0)
374 {
375 /* allocate buffer */
376 p = pbuf_alloc(PBUF_RAW, ecm_eth_dev->rx_size, PBUF_RAM);
377 if (p != RT_NULL)
378 {
379 struct pbuf* q;
380
381 for (q = p; q != RT_NULL; q= q->next)
382 {
383 /* Copy the received frame into buffer from memory pointed by the current ETHERNET DMA Rx descriptor */
384 rt_memcpy(q->payload,
385 (rt_uint8_t *)((ecm_eth_dev->rx_buffer) + offset),
386 q->len);
387 offset += q->len;
388 }
389 }
390 }
391
392 {
393 if(ecm_eth_dev->func->device->state == USB_STATE_CONFIGURED)
394 {
395 ecm_eth_dev->rx_size = 0;
396 ecm_eth_dev->rx_offset = 0;
397 ecm_eth_dev->eps.ep_out->request.buffer = ecm_eth_dev->eps.ep_out->buffer;
398 ecm_eth_dev->eps.ep_out->request.size = EP_MAXPACKET(ecm_eth_dev->eps.ep_out);
399 ecm_eth_dev->eps.ep_out->request.req_type = UIO_REQUEST_READ_BEST;
400 rt_usbd_io_request(ecm_eth_dev->func->device, ecm_eth_dev->eps.ep_out, &ecm_eth_dev->eps.ep_out->request);
401 }
402 }
403
404 return p;
405}
406
407rt_err_t rt_ecm_eth_tx(rt_device_t dev, struct pbuf* p)
408{

Callers

nothing calls this directly

Calls 3

rt_memcpyFunction · 0.85
rt_usbd_io_requestFunction · 0.85
pbuf_allocFunction · 0.50

Tested by

no test coverage detected