Changeset c804484 in mainline
- Timestamp:
- 2011-12-12T13:14:09Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3538b0e
- Parents:
- 1561e8b
- Location:
- uspace/lib/usbdev
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/include/usb/dev/pipes.h
r1561e8b rc804484 44 44 #include <usb/dev/usb_device_connection.h> 45 45 46 #define CTRL_PIPE_MIN_PACKET_SIZE 8 46 47 /** Abstraction of a logical connection to USB device endpoint. 47 48 * It encapsulates endpoint attributes (transfer type etc.) as well … … 80 81 } usb_pipe_t; 81 82 82 83 83 /** Description of endpoint characteristics. */ 84 84 typedef struct { … … 115 115 } usb_endpoint_mapping_t; 116 116 117 118 117 int usb_pipe_initialize(usb_pipe_t *, usb_device_connection_t *, 119 118 usb_endpoint_t, usb_transfer_type_t, size_t, usb_direction_t); … … 124 123 int usb_pipe_initialize_from_configuration(usb_endpoint_mapping_t *, 125 124 size_t, const uint8_t *, size_t, usb_device_connection_t *); 125 126 126 int usb_pipe_register(usb_pipe_t *, unsigned); 127 127 int usb_pipe_unregister(usb_pipe_t *); -
uspace/lib/usbdev/src/pipes.c
r1561e8b rc804484 292 292 return usb_pipe_write_no_check(pipe, 0, buffer, size); 293 293 } 294 /*----------------------------------------------------------------------------*/ 295 /** Initialize USB endpoint pipe. 296 * 297 * @param pipe Endpoint pipe to be initialized. 298 * @param connection Connection to the USB device backing this pipe (the wire). 299 * @param endpoint_no Endpoint number (in USB 1.1 in range 0 to 15). 300 * @param transfer_type Transfer type (e.g. interrupt or bulk). 301 * @param max_packet_size Maximum packet size in bytes. 302 * @param direction Endpoint direction (in/out). 303 * @return Error code. 304 */ 305 int usb_pipe_initialize(usb_pipe_t *pipe, 306 usb_device_connection_t *connection, usb_endpoint_t endpoint_no, 307 usb_transfer_type_t transfer_type, size_t max_packet_size, 308 usb_direction_t direction) 309 { 310 assert(pipe); 311 assert(connection); 312 313 fibril_mutex_initialize(&pipe->guard); 314 pipe->wire = connection; 315 pipe->endpoint_no = endpoint_no; 316 pipe->transfer_type = transfer_type; 317 pipe->max_packet_size = max_packet_size; 318 pipe->direction = direction; 319 pipe->auto_reset_halt = false; 320 321 return EOK; 322 } 323 /*----------------------------------------------------------------------------*/ 324 /** Initialize USB endpoint pipe as the default zero control pipe. 325 * 326 * @param pipe Endpoint pipe to be initialized. 327 * @param connection Connection to the USB device backing this pipe (the wire). 328 * @return Error code. 329 */ 330 int usb_pipe_initialize_default_control(usb_pipe_t *pipe, 331 usb_device_connection_t *connection) 332 { 333 assert(pipe); 334 assert(connection); 335 336 int rc = usb_pipe_initialize(pipe, connection, 0, USB_TRANSFER_CONTROL, 337 CTRL_PIPE_MIN_PACKET_SIZE, USB_DIRECTION_BOTH); 338 339 pipe->auto_reset_halt = true; 340 341 return rc; 342 } 343 /*----------------------------------------------------------------------------*/ 344 /** Register endpoint with the host controller. 345 * 346 * @param pipe Pipe to be registered. 347 * @param interval Polling interval. 348 * @return Error code. 349 */ 350 int usb_pipe_register(usb_pipe_t *pipe, unsigned interval) 351 { 352 assert(pipe); 353 assert(pipe->wire); 354 355 return usb_device_register_endpoint(pipe->wire, 356 pipe->endpoint_no, pipe->transfer_type, 357 pipe->direction, pipe->max_packet_size, interval); 358 } 359 /*----------------------------------------------------------------------------*/ 360 /** Revert endpoint registration with the host controller. 361 * 362 * @param pipe Pipe to be unregistered. 363 * @return Error code. 364 */ 365 int usb_pipe_unregister(usb_pipe_t *pipe) 366 { 367 assert(pipe); 368 assert(pipe->wire); 369 370 return usb_device_unregister_endpoint(pipe->wire, 371 pipe->endpoint_no, pipe->direction); 372 } 373 294 374 /** 295 375 * @} -
uspace/lib/usbdev/src/pipesinit.c
r1561e8b rc804484 41 41 #include <assert.h> 42 42 43 #define CTRL_PIPE_MIN_PACKET_SIZE 844 43 #define DEV_DESCR_MAX_PACKET_SIZE_OFFSET 7 45 46 44 47 45 #define NESTING(parentname, childname) \ … … 326 324 327 325 return EOK; 328 }329 330 /** Initialize USB endpoint pipe.331 *332 * @param pipe Endpoint pipe to be initialized.333 * @param connection Connection to the USB device backing this pipe (the wire).334 * @param endpoint_no Endpoint number (in USB 1.1 in range 0 to 15).335 * @param transfer_type Transfer type (e.g. interrupt or bulk).336 * @param max_packet_size Maximum packet size in bytes.337 * @param direction Endpoint direction (in/out).338 * @return Error code.339 */340 int usb_pipe_initialize(usb_pipe_t *pipe,341 usb_device_connection_t *connection, usb_endpoint_t endpoint_no,342 usb_transfer_type_t transfer_type, size_t max_packet_size,343 usb_direction_t direction)344 {345 assert(pipe);346 assert(connection);347 348 fibril_mutex_initialize(&pipe->guard);349 pipe->wire = connection;350 pipe->endpoint_no = endpoint_no;351 pipe->transfer_type = transfer_type;352 pipe->max_packet_size = max_packet_size;353 pipe->direction = direction;354 pipe->auto_reset_halt = false;355 356 return EOK;357 }358 359 /** Initialize USB endpoint pipe as the default zero control pipe.360 *361 * @param pipe Endpoint pipe to be initialized.362 * @param connection Connection to the USB device backing this pipe (the wire).363 * @return Error code.364 */365 int usb_pipe_initialize_default_control(usb_pipe_t *pipe,366 usb_device_connection_t *connection)367 {368 assert(pipe);369 assert(connection);370 371 int rc = usb_pipe_initialize(pipe, connection, 0, USB_TRANSFER_CONTROL,372 CTRL_PIPE_MIN_PACKET_SIZE, USB_DIRECTION_BOTH);373 374 pipe->auto_reset_halt = true;375 376 return rc;377 326 } 378 327 … … 428 377 } 429 378 430 /** Register endpoint with the host controller.431 *432 * @param pipe Pipe to be registered.433 * @param interval Polling interval.434 * @return Error code.435 */436 int usb_pipe_register(usb_pipe_t *pipe, unsigned interval)437 {438 assert(pipe);439 assert(pipe->wire);440 441 return usb_device_register_endpoint(pipe->wire,442 pipe->endpoint_no, pipe->transfer_type,443 pipe->direction, pipe->max_packet_size, interval);444 }445 446 /** Revert endpoint registration with the host controller.447 *448 * @param pipe Pipe to be unregistered.449 * @return Error code.450 */451 int usb_pipe_unregister(usb_pipe_t *pipe)452 {453 assert(pipe);454 assert(pipe->wire);455 456 return usb_device_unregister_endpoint(pipe->wire,457 pipe->endpoint_no, pipe->direction);458 }459 460 379 /** 461 380 * @}
Note:
See TracChangeset
for help on using the changeset viewer.