source: mainline/uspace/lib/usb/src/drvpsync.c@ 90fb679

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 90fb679 was 90fb679, checked in by Vojtech Horky <vojtechhorky@…>, 15 years ago

Add pseudo-synchronous USB transfers

  • Property mode set to 100644
File size: 3.7 KB
RevLine 
[90fb679]1/*
2 * Copyright (c) 2010 Vojtech Horky
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 libusb usb
30 * @{
31 */
32/** @file
33 * @brief Implementation of pseudo-synchronous transfers.
34 */
35#include <usb/usbdrv.h>
36#include <usbhc_iface.h>
37#include <errno.h>
38
39int usb_drv_psync_interrupt_out(int phone, usb_target_t target,
40 void *buffer, size_t size)
41{
42 usb_handle_t h;
43 int rc;
44 rc = usb_drv_async_interrupt_out(phone, target, buffer, size, &h);
45 if (rc != EOK) {
46 return rc;
47 }
48 return usb_drv_async_wait_for(h);
49}
50
51int usb_drv_psync_interrupt_in(int phone, usb_target_t target,
52 void *buffer, size_t size, size_t *actual_size)
53{
54 usb_handle_t h;
55 int rc;
56 rc = usb_drv_async_interrupt_in(phone, target, buffer, size,
57 actual_size, &h);
58 if (rc != EOK) {
59 return rc;
60 }
61 return usb_drv_async_wait_for(h);
62}
63
64
65
66int usb_drv_psync_control_write_setup(int phone, usb_target_t target,
67 void *buffer, size_t size)
68{
69 usb_handle_t h;
70 int rc;
71 rc = usb_drv_async_control_write_setup(phone, target, buffer, size, &h);
72 if (rc != EOK) {
73 return rc;
74 }
75 return usb_drv_async_wait_for(h);
76}
77
78int usb_drv_psync_control_write_data(int phone, usb_target_t target,
79 void *buffer, size_t size)
80{
81 usb_handle_t h;
82 int rc;
83 rc = usb_drv_async_control_write_data(phone, target, buffer, size, &h);
84 if (rc != EOK) {
85 return rc;
86 }
87 return usb_drv_async_wait_for(h);
88}
89
90int usb_drv_psync_control_write_status(int phone, usb_target_t target)
91{
92 usb_handle_t h;
93 int rc;
94 rc = usb_drv_async_control_write_status(phone, target, &h);
95 if (rc != EOK) {
96 return rc;
97 }
98 return usb_drv_async_wait_for(h);
99}
100
101
102
103int usb_drv_psync_control_read_setup(int phone, usb_target_t target,
104 void *buffer, size_t size)
105{
106 usb_handle_t h;
107 int rc;
108 rc = usb_drv_async_control_read_setup(phone, target, buffer, size, &h);
109 if (rc != EOK) {
110 return rc;
111 }
112 return usb_drv_async_wait_for(h);
113}
114
115int usb_drv_psync_control_read_data(int phone, usb_target_t target,
116 void *buffer, size_t size, size_t *actual_size)
117{
118 usb_handle_t h;
119 int rc;
120 rc = usb_drv_async_control_read_data(phone, target, buffer, size,
121 actual_size, &h);
122 if (rc != EOK) {
123 return rc;
124 }
125 return usb_drv_async_wait_for(h);
126}
127
128int usb_drv_psync_control_read_status(int phone, usb_target_t target)
129{
130 usb_handle_t h;
131 int rc;
132 rc = usb_drv_async_control_read_status(phone, target, &h);
133 if (rc != EOK) {
134 return rc;
135 }
136 return usb_drv_async_wait_for(h);
137}
138
139/**
140 * @}
141 */
Note: See TracBrowser for help on using the repository browser.