Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 19387b61 in mainline


Ignore:
Timestamp:
2011-05-11T19:03:56Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
70c12d6
Parents:
a81a1d09
Message:

Add wrappers for endpoint status and clear halt

Location:
uspace/lib/usbdev
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/include/usb/request.h

    ra81a1d09 r19387b61  
    142142
    143143int usb_request_clear_endpoint_halt(usb_pipe_t *, uint16_t);
     144int usb_pipe_clear_halt(usb_pipe_t *, usb_pipe_t *);
     145int usb_request_get_endpoint_status(usb_pipe_t *, usb_pipe_t *, uint16_t *);
    144146
    145147#endif
  • uspace/lib/usbdev/src/request.c

    ra81a1d09 r19387b61  
    885885}
    886886
     887/** Clear halt bit of an endpoint pipe (after pipe stall).
     888 *
     889 * @param ctrl_pipe Control pipe.
     890 * @param target_pipe Which pipe is halted and shall be cleared.
     891 * @return Error code.
     892 */
     893int usb_pipe_clear_halt(usb_pipe_t *ctrl_pipe, usb_pipe_t *target_pipe)
     894{
     895        if ((ctrl_pipe == NULL) || (target_pipe == NULL)) {
     896                return EINVAL;
     897        }
     898        return usb_request_clear_endpoint_halt(ctrl_pipe,
     899            target_pipe->endpoint_no);
     900}
     901
     902/** Get endpoint status.
     903 *
     904 * @param[in] ctrl_pipe Control pipe.
     905 * @param[in] pipe Of which pipe the status shall be received.
     906 * @param[out] status Where to store pipe status (in native endianness).
     907 * @return Error code.
     908 */
     909int usb_request_get_endpoint_status(usb_pipe_t *ctrl_pipe, usb_pipe_t *pipe,
     910    uint16_t *status)
     911{
     912        uint16_t status_tmp;
     913        uint16_t pipe_index = (uint16_t) pipe->endpoint_no;
     914        int rc = usb_request_get_status(ctrl_pipe,
     915            USB_REQUEST_RECIPIENT_ENDPOINT, uint16_host2usb(pipe_index),
     916            &status_tmp);
     917        if (rc != EOK) {
     918                return rc;
     919        }
     920
     921        if (status != NULL) {
     922                *status = uint16_usb2host(status_tmp);
     923        }
     924
     925        return EOK;
     926}
     927
    887928/**
    888929 * @}
Note: See TracChangeset for help on using the changeset viewer.