3 Copyright (C) Dean Camera, 2011.
5 dean [at] fourwalledcubicle [dot] com
10 Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
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.
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
32 * \brief USB host standard request management.
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.
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.
41 #ifndef __HOSTSTDREQ_H__
42 #define __HOSTSTDREQ_H__
49 #include "StdRequestType.h"
50 #include "../LowLevel/USBController.h"
52 /* Enable C linkage for C++ Compilers: */
53 #if defined(__cplusplus)
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.
62 /* Public Interface - May be used in end-application: */
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.
67 * \ingroup Group_PipeControlReq
69 enum USB_Host_SendControlErrorCodes_t
71 HOST_SENDCONTROL_Successful
= 0, /**< No error occurred in the request transfer. */
72 HOST_SENDCONTROL_DeviceDisconnected
= 1, /**< The attached device was disconnected during the
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.
79 HOST_SENDCONTROL_SoftwareTimeOut
= 4, /**< The request or data transfer timed out. */
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.
87 * \ingroup Group_PipeControlReq
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.
92 * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
94 uint8_t USB_Host_SendControlRequest(void* const BufferPtr
);
96 /* Private Interface - For use in library only: */
97 #if !defined(__DOXYGEN__)
99 enum USB_WaitForTypes_t
101 USB_HOST_WAITFOR_SetupSent
,
102 USB_HOST_WAITFOR_InReceived
,
103 USB_HOST_WAITFOR_OutReady
,
106 /* Function Prototypes: */
107 #if defined(__INCLUDE_FROM_HOSTSTDREQ_C)
108 static uint8_t USB_Host_WaitForIOS(const uint8_t WaitType
);
112 /* Disable C linkage for C++ Compilers: */
113 #if defined(__cplusplus)