Changeset 3f42eab in mainline
- Timestamp:
- 2018-01-05T22:50:13Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c901632
- Parents:
- 86650db
- Location:
- uspace/lib/usbdev
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/include/usb/dev/pipes.h
r86650db r3f42eab 103 103 int usb_pipe_initialize_default_control(usb_pipe_t *, usb_dev_session_t *); 104 104 105 int usb_pipe_probe_default_control(usb_pipe_t *);106 105 int usb_pipe_initialize_from_configuration(usb_endpoint_mapping_t *, 107 106 size_t, const uint8_t *, size_t, usb_dev_session_t *); -
uspace/lib/usbdev/src/pipesinit.c
r86650db r3f42eab 379 379 } 380 380 381 /** Probe default control pipe for max packet size.382 *383 * The function tries to get the correct value of max packet size several384 * time before giving up.385 *386 * The session on the pipe shall not be started.387 *388 * @param pipe Default control pipe.389 * @return Error code.390 */391 int usb_pipe_probe_default_control(usb_pipe_t *pipe)392 {393 assert(pipe);394 static_assert(DEV_DESCR_MAX_PACKET_SIZE_OFFSET < CTRL_PIPE_MIN_PACKET_SIZE);395 396 if ((pipe->desc.direction != USB_DIRECTION_BOTH) ||397 (pipe->desc.transfer_type != USB_TRANSFER_CONTROL) ||398 (pipe->desc.endpoint_no != 0)) {399 return EINVAL;400 }401 402 uint8_t dev_descr_start[CTRL_PIPE_MIN_PACKET_SIZE];403 size_t transferred_size;404 int rc;405 for (size_t attempt_var = 0; attempt_var < 3; ++attempt_var) {406 rc = usb_request_get_descriptor(pipe, USB_REQUEST_TYPE_STANDARD,407 USB_REQUEST_RECIPIENT_DEVICE, USB_DESCTYPE_DEVICE,408 0, 0, dev_descr_start, CTRL_PIPE_MIN_PACKET_SIZE,409 &transferred_size);410 if (rc == EOK) {411 if (transferred_size != CTRL_PIPE_MIN_PACKET_SIZE) {412 rc = ELIMIT;413 continue;414 }415 break;416 }417 }418 if (rc != EOK) {419 return rc;420 }421 422 pipe->desc.max_packet_size423 = dev_descr_start[DEV_DESCR_MAX_PACKET_SIZE_OFFSET];424 425 return EOK;426 }427 428 381 /** 429 382 * @}
Note:
See TracChangeset
for help on using the changeset viewer.