Fixed GenericHIDHost demo report write routine incorrect for control type requests...
[pub/USBasp.git] / LUFA / Drivers / USB / HighLevel / StreamCallbacks.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2009.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, and distribute this software
13 and its documentation for any purpose and without fee is hereby
14 granted, provided that the above copyright notice appear in all
15 copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
20
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
28 this software.
29 */
30
31 /** \file
32 *
33 * Macros and enums for the stream callback routines in Endpoint.h and Pipe.c. This module contains the
34 * code required to easily set up stream callback functions which can be used to force early abort of a
35 * stream read/write process.
36 */
37
38 /** \ingroup Group_USB
39 * @defgroup Group_StreamCallbacks Endpoint and Pipe Stream Callbacks
40 *
41 * Functions, macros, variables, enums and types related to endpoint and pipe stream callback functions.
42 *
43 * @{
44 */
45
46 #ifndef __STREAMCALLBACK_H__
47 #define __STREAMCALLBACK_H__
48
49 /* Public Interface - May be used in end-application: */
50 /* Macros: */
51 /** Creates a prototype for or begins a stream callback routine. Stream callback routines are small
52 * routines which are executed during stream read or writes (if the callback-enabled versions of
53 * these functions are used) which allow the user application to abort the transfer when certain
54 * arbitrary conditions are met.
55 *
56 * Stream callback functions should return a value from the StreamCallback_Return_ErrorCodes_t
57 * enum.
58 *
59 * Usage Example (Device Endpoint, but applicable for Host Pipes also):
60 * \code
61 * STREAM_CALLBACK(GlobalNotSet); // Callback Prototype
62 *
63 * STREAM_CALLBACK(GlobalNotSet)
64 * {
65 * if (MyGlobal == false)
66 * return ENDPOINT_STREAMCALLBACK_Continue;
67 * else
68 * return ENDPOINT_STREAMCALLBACK_Abort;
69 * }
70 *
71 * //...
72 * // Inside some routine:
73 * if (Endpoint_Write_Stream_LE(DataBuffer, sizeof(DataBuffer), GlobalNotSet) ==
74 * ENDPOINT_RWSTREAM_ERROR_CallbackAborted)
75 * {
76 * // Do something when the callback aborted the transfer early
77 * }
78 * \endcode
79 */
80 #define STREAM_CALLBACK(name) uint8_t name (void)
81
82 /** Used with the Endpoint and Pipe stream functions as the callback function parameter, indicating that the stream
83 * call has no callback function to be called between USB packets.
84 */
85 #define NO_STREAM_CALLBACK NULL
86
87 /* Enums: */
88 /** Enum for the possible error return codes of a stream callback function */
89 enum StreamCallback_Return_ErrorCodes_t
90 {
91 STREAMCALLBACK_Continue = 0, /**< Continue sending or receiving the stream. */
92 STREAMCALLBACK_Abort = 1, /**< Abort the stream send or receiving process. */
93 };
94
95 #endif
96
97 /** @} */