乐鑫技术交流
直播中

杨火亭

7年用户 989经验值
擅长:控制/MCU
私信 关注
[问答]

hcd.c中的zero_len_packet标志设置问题求解

MASTER版本。见红色字体,疑问:bulk transfer附加0长度报文应该只针对out方向吧?我理解应该是!is_in ...



static inline void _buffer_fill_bulk(dma_buffer_block_t *buffer, usb_transfer_t *transfer, bool is_in)

{

    if (is_in) {

        usbh_hal_xfer_desc_fill(buffer->xfer_desc_list, 0, transfer->data_buffer, transfer->num_bytes,

                                USBH_HAL_XFER_DESC_FLAG_IN | USBH_HAL_XFER_DESC_FLAG_HOC);

    } else if (transfer->flags & USB_TRANSFER_FLAG_ZERO_PACK) {

        //We need to add an extra zero length packet, so two descriptors are used

        usbh_hal_xfer_desc_fill(buffer->xfer_desc_list, 0, transfer->data_buffer, transfer->num_bytes, 0);

        usbh_hal_xfer_desc_fill(buffer->xfer_desc_list, 1, NULL, 0, USBH_HAL_XFER_DESC_FLAG_HOC);

    } else {

        usbh_hal_xfer_desc_fill(buffer->xfer_desc_list, 0, transfer->data_buffer, transfer->num_bytes, USBH_HAL_XFER_DESC_FLAG_HOC);

    }

    //Update buffer flags

    buffer->flags.bulk.zero_len_packet = (is_in && (transfer->flags & USB_TRANSFER_FLAG_ZERO_PACK)) ? 1 : 0;

}

更多回帖

发帖
×
20
完善资料,
赚取积分