a73ccd26ffea064efc24fa8cfc55512cb7fd75c7
[pub/USBasp.git] / LUFA / Drivers / USB / HighLevel / HostStandardReq.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2011.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.lufa-lib.org
7 */
8
9 /*
10 Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, distribute, and sell this
13 software and its documentation for any purpose is hereby granted
14 without fee, provided that the above copyright notice appear in
15 all 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 * \brief USB host standard request management.
33 *
34 * This file contains the function prototypes necessary for the issuing of outgoing standard control requests
35 * when the library is in USB host mode.
36 *
37 * \note This file should not be included directly. It is automatically included as needed by the USB driver
38 * dispatch header located in LUFA/Drivers/USB/USB.h.
39 */
40
41 #ifndef __HOSTSTDREQ_H__
42 #define __HOSTSTDREQ_H__
43
44 /* Includes: */
45 #include <stdint.h>
46 #include <stdbool.h>
47
48 #include "USBMode.h"
49 #include "StdRequestType.h"
50 #include "../LowLevel/USBController.h"
51
52 /* Enable C linkage for C++ Compilers: */
53 #if defined(__cplusplus)
54 extern "C" {
55 #endif
56
57 /* Preprocessor Checks: */
58 #if !defined(__INCLUDE_FROM_USB_DRIVER)
59 #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
60 #endif
61
62 /* Public Interface - May be used in end-application: */
63 /* Enums: */
64 /** Enum for the \ref USB_Host_SendControlRequest() return code, indicating the reason for the error
65 * if the transfer of the request is unsuccessful.
66 *
67 * \ingroup Group_PipeControlReq
68 */
69 enum USB_Host_SendControlErrorCodes_t
70 {
71 HOST_SENDCONTROL_Successful = 0, /**< No error occurred in the request transfer. */
72 HOST_SENDCONTROL_DeviceDisconnected = 1, /**< The attached device was disconnected during the
73 * request transfer.
74 */
75 HOST_SENDCONTROL_PipeError = 2, /**< An error occurred in the pipe while sending the request. */
76 HOST_SENDCONTROL_SetupStalled = 3, /**< The attached device stalled the request, usually
77 * indicating that the request is unsupported on the device.
78 */
79 HOST_SENDCONTROL_SoftwareTimeOut = 4, /**< The request or data transfer timed out. */
80 };
81
82 /* Function Prototypes: */
83 /** Sends the request stored in the \ref USB_ControlRequest global structure to the attached device,
84 * and transfers the data stored in the buffer to the device, or from the device to the buffer
85 * as requested. The transfer is made on the currently selected pipe.
86 *
87 * \ingroup Group_PipeControlReq
88 *
89 * \param[in] BufferPtr Pointer to the start of the data buffer if the request has a data stage, or
90 * NULL if the request transfers no data to or from the device.
91 *
92 * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
93 */
94 uint8_t USB_Host_SendControlRequest(void* const BufferPtr);
95
96 /* Private Interface - For use in library only: */
97 #if !defined(__DOXYGEN__)
98 /* Enums: */
99 enum USB_WaitForTypes_t
100 {
101 USB_HOST_WAITFOR_SetupSent,
102 USB_HOST_WAITFOR_InReceived,
103 USB_HOST_WAITFOR_OutReady,
104 };
105
106 /* Function Prototypes: */
107 #if defined(__INCLUDE_FROM_HOSTSTDREQ_C)
108 static uint8_t USB_Host_WaitForIOS(const uint8_t WaitType);
109 #endif
110 #endif
111
112 /* Disable C linkage for C++ Compilers: */
113 #if defined(__cplusplus)
114 }
115 #endif
116
117 #endif
118