source: mainline/uspace/lib/usbdev/include/usb/dev/poll.h@ 162726b

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

Fix Doxygen groups of USB libraries

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 * Copyright (c) 2011 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 libusbdev
30 * @{
31 */
32/** @file
33 * USB device polling functions.
34 */
35#ifndef LIBUSBDEV_POLL_H_
36#define LIBUSBDEV_POLL_H_
37
38#include <usb/dev/driver.h>
39#include <time.h>
40
41typedef struct {
42 /** Level of debugging messages from auto polling.
43 * 0 - nothing
44 * 1 - inform about errors and polling start/end
45 * 2 - also dump every retrieved buffer
46 */
47 int debug;
48 /** Maximum number of consecutive errors before polling termination. */
49 size_t max_failures;
50 /** Delay between poll requests in milliseconds.
51 * Set to negative value to use value from endpoint descriptor.
52 */
53 int delay;
54 /** Whether to automatically try to clear the HALT feature after
55 * the endpoint stalls.
56 */
57 bool auto_clear_halt;
58 /** Callback when data arrives.
59 *
60 * @param dev Device that was polled.
61 * @param data Data buffer (in USB endianness).
62 * @param data_size Size of the @p data buffer in bytes.
63 * @param arg Custom argument.
64 * @return Whether to continue in polling.
65 */
66 bool (*on_data)(usb_device_t *dev, uint8_t *data, size_t data_size,
67 void *arg);
68 /** Callback when polling is terminated.
69 *
70 * @param dev Device where the polling was terminated.
71 * @param due_to_errors Whether polling stopped due to several failures.
72 * @param arg Custom argument.
73 */
74 void (*on_polling_end)(usb_device_t *dev, bool due_to_errors,
75 void *arg);
76 /** Callback when error occurs.
77 *
78 * @param dev Device where error occurred.
79 * @param err_code Error code (as returned from usb_pipe_read).
80 * @param arg Custom argument.
81 * @return Whether to continue in polling.
82 */
83 bool (*on_error)(usb_device_t *dev, int err_code, void *arg);
84} usb_device_auto_polling_t;
85
86int usb_device_auto_polling(usb_device_t *, size_t, usb_device_auto_polling_t *,
87 size_t, void *);
88
89typedef bool (*usb_polling_callback_t)(usb_device_t *,
90 uint8_t *, size_t, void *);
91typedef void (*usb_polling_terminted_callback_t)(usb_device_t *, bool, void *);
92
93int usb_device_auto_poll(usb_device_t *, size_t,
94 usb_polling_callback_t, size_t, usb_polling_terminted_callback_t, void *);
95
96#endif
97/**
98 * @}
99 */
Note: See TracBrowser for help on using the repository browser.