Fixed minor issue with the RNDISEthernet demo DHCP protocol decoder routine using...
[pub/USBasp.git] / LUFA / Drivers / USB / LowLevel / HostChapter9.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 * Module for host mode request processing. This module allows for the transmission of standard, class and
34 * vendor control requests to the default control endpoint of an attached device while in host mode.
35 *
36 * \see Chapter 9 of the USB 2.0 specification.
37 */
38
39 #ifndef __HOSTCHAPTER9_H__
40 #define __HOSTCHAPTER9_H__
41
42 /* Includes: */
43 #include <avr/io.h>
44 #include <stdbool.h>
45
46 #include "LowLevel.h"
47 #include "../HighLevel/USBMode.h"
48 #include "../HighLevel/StdRequestType.h"
49
50 /* Enable C linkage for C++ Compilers: */
51 #if defined(__cplusplus)
52 extern "C" {
53 #endif
54
55 /* Public Interface - May be used in end-application: */
56 /* Type Defines: */
57 /** Type define for a standard USB control request.
58 *
59 * \see StdRequestType.h for information on the request type and data.
60 * \see The USB 2.0 specification for more information on standard control requests.
61 */
62 typedef struct
63 {
64 uint8_t bmRequestType; /**< Type of the request. */
65 uint8_t bRequest; /**< Request command code. */
66 uint16_t wValue; /**< wValue parameter of the request. */
67 uint16_t wIndex; /**< wIndex parameter of the request. */
68 uint16_t wLength; /**< Length of the data to transfer in bytes. */
69 } USB_Host_Request_Header_t;
70
71 /* Enums: */
72 /** Enum for the USB_Host_SendControlRequest() return code, indicating the reason for the error
73 * if the transfer of the request is unsuccessful.
74 */
75 enum USB_Host_SendControlErrorCodes_t
76 {
77 HOST_SENDCONTROL_Successful = 0, /**< No error occurred in the request transfer. */
78 HOST_SENDCONTROL_DeviceDisconnect = 1, /**< The attached device was disconnected during the
79 * request transfer.
80 */
81 HOST_SENDCONTROL_PipeError = 2, /**< An error occurred in the pipe while sending the request. */
82 HOST_SENDCONTROL_SetupStalled = 3, /**< The attached device stalled the request, usually
83 * indicating that the request is unsupported on the device.
84 */
85 HOST_SENDCONTROL_SoftwareTimeOut = 4, /**< The request or data transfer timed out. */
86 };
87
88 /* Global Variables: */
89 /** Global for the request to send via the USB_Host_SendControlRequest() function. This
90 * global should be filled with the correct control request data before sending the request to
91 * the attached device while in host mode.
92 */
93 extern USB_Host_Request_Header_t USB_HostRequest;
94
95 /* Function Prototypes: */
96 /** Sends the request stored in the USB_HostRequest global structure to the attached device,
97 * and transfers the data stored in the buffer to the device, or from the device to the buffer
98 * as requested. The transfer is made on the currently selected pipe.
99 *
100 * \param BufferPtr Pointer to the start of the data buffer if the request has a data stage, or
101 * NULL if the request transfers no data to or from the device.
102 *
103 * \return A value from the USB_Host_SendControlErrorCodes_t enum to indicate the result.
104 */
105 uint8_t USB_Host_SendControlRequest(void* BufferPtr);
106
107 /* Private Interface - For use in library only: */
108 #if !defined(__DOXYGEN__)
109 /* Enums: */
110 enum USB_WaitForTypes_t
111 {
112 USB_HOST_WAITFOR_SetupSent,
113 USB_HOST_WAITFOR_InReceived,
114 USB_HOST_WAITFOR_OutReady,
115 };
116
117 /* Function Prototypes: */
118 #if defined(INCLUDE_FROM_HOSTCHAPTER9_C)
119 static uint8_t USB_Host_Wait_For_Setup_IOS(const uint8_t WaitType);
120 #endif
121 #endif
122
123 /* Disable C linkage for C++ Compilers: */
124 #if defined(__cplusplus)
125 }
126 #endif
127
128 #endif