source: mainline/uspace/lib/usbhost/include/usb/host/usb_transfer_batch.h@ d37514e

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since d37514e was a5b3de6, checked in by Ondřej Hlavatý <aearsis@…>, 8 years ago

usbhost endpoint: removed target

The reasons for having usb_target_t inside endpoint have been dismissed. Enpoint is not a target of a transaction, so this was just misleading.

  • Property mode set to 100644
File size: 3.7 KB
Line 
1/*
2 * Copyright (c) 2011 Jan Vesely
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup libusbhost
30 * @{
31 */
32/** @file
33 * USB transfer transaction structures.
34 */
35
36#ifndef LIBUSBHOST_HOST_USB_TRANSFER_BATCH_H
37#define LIBUSBHOST_HOST_USB_TRANSFER_BATCH_H
38
39#include <usb/usb.h>
40#include <usb/request.h>
41
42#include <stddef.h>
43#include <stdint.h>
44#include <usbhc_iface.h>
45
46#define USB_SETUP_PACKET_SIZE 8
47
48typedef struct endpoint endpoint_t;
49typedef struct bus bus_t;
50typedef struct usb_transfer_batch usb_transfer_batch_t;
51
52/** Callback to be called on transfer. */
53typedef int (*usb_transfer_batch_callback_t)(usb_transfer_batch_t *);
54
55/** Structure stores additional data needed for communication with EP */
56typedef struct usb_transfer_batch {
57 /** Target for communication */
58 usb_target_t target;
59
60 /** Endpoint used for communication */
61 endpoint_t *ep;
62
63 /** Size reported to be sent */
64 size_t expected_size;
65
66 /** Direction of the transfer */
67 usb_direction_t dir;
68
69 /** Function called on completion */
70 usb_transfer_batch_callback_t on_complete;
71 /** Arbitrary data for the handler */
72 void *on_complete_data;
73
74 /** Place to store SETUP data needed by control transfers */
75 union {
76 char buffer [USB_SETUP_PACKET_SIZE];
77 usb_device_request_setup_packet_t packet;
78 uint64_t packed;
79 } setup;
80
81 /** Resetting the Toggle */
82 toggle_reset_mode_t toggle_reset_mode;
83
84 /** Place for data to send/receive */
85 char *buffer;
86 /** Size of memory pointed to by buffer member */
87 size_t buffer_size;
88
89 /** Actually used portion of the buffer */
90 size_t transfered_size;
91 /** Indicates success/failure of the communication */
92 int error;
93} usb_transfer_batch_t;
94
95/** Printf formatting string for dumping usb_transfer_batch_t. */
96#define USB_TRANSFER_BATCH_FMT "[%d:%d %s %s-%s %zuB/%zu]"
97
98/** Printf arguments for dumping usb_transfer_batch_t.
99 * @param batch USB transfer batch to be dumped.
100 */
101#define USB_TRANSFER_BATCH_ARGS(batch) \
102 (batch).target.address, (batch).target.endpoint, \
103 usb_str_speed((batch).ep->speed), \
104 usb_str_transfer_type_short((batch).ep->transfer_type), \
105 usb_str_direction((batch).ep->direction), \
106 (batch).buffer_size, (batch).ep->max_packet_size
107
108void usb_transfer_batch_init(usb_transfer_batch_t *, endpoint_t *);
109void usb_transfer_batch_finish(usb_transfer_batch_t *);
110
111usb_transfer_batch_t *usb_transfer_batch_create(endpoint_t *);
112void usb_transfer_batch_destroy(usb_transfer_batch_t *);
113
114#endif
115
116/**
117 * @}
118 */
Note: See TracBrowser for help on using the repository browser.