USBD_DrvEP_Rx

Description

Receive the specified amount of data from device endpoint.

Files

Every device driver’s usbd_drv.c

Prototype

static  CPU_INT32U  USBD_DrvEP_Rx (USBD_DRV    *p_drv,
                                   CPU_INT08U   ep_addr,
                                   CPU_INT08U  *p_buf,
                                   CPU_INT32U   buf_len,
                                   USBD_ERR    *p_err);


Arguments

p_drv

Pointer to USB device driver structure.

ep_addr

Endpoint address.

p_buf

Pointer to data buffer.

buf_len

Length of the buffer.

p_err

Pointer to variable that will receive the return error code from this function.

Returned Value

Number of octets received, if NO error(s)

0, otherwise

Callers

USB device core layer.

Notes / Warnings

  1. Typically, the receive from endpoint function performs the following operations:
    1. Check if packet has been received and is ready to be read.
    2. Determine packet length.
    3. Copy the data received into the buffer referenced by p_buf. If the USB device controller is working in DMA mode, no CPU copy will be required as it was already done by the DMA engine of the USB device controller.
    4. If an error occurred during the transfer (i.e. overflow or buffer error), the function must set the value of p_err to USBD_ERR_RX and treat the transfer data as invalid.
    5. Clear endpoint buffer to allow next packet to be received. For some controllers, this may not be necessary.