Board Dataflash driver now allows for dataflash ICs which use different shifts for...
[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 "StdRequestType.h"
48
49 /* Enable C linkage for C++ Compilers: */
50 #if defined(__cplusplus)
51 extern "C" {
52 #endif
53
54 /* Public Interface - May be used in end-application: */
55 /* Type Defines: */
56 /** Type define for a standard USB control request.
57 *
58 * \see StdRequestType.h for information on the request type and data.
59 * \see The USB 2.0 specification for more information on standard control requests.
60 */
61 typedef struct
62 {
63 uint8_t bmRequestType; /**< Type of the request. */
64 uint8_t bRequest; /**< Request command code. */
65 uint16_t wValue; /**< wValue parameter of the request. */
66 uint16_t wIndex; /**< wIndex parameter of the request. */
67 uint16_t wLength; /**< Length of the data to transfer in bytes. */
68 } USB_Host_Request_Header_t;
69
70 /* Enums: */
71 /** Enum for the USB_Host_SendControlRequest() return code, indicating the reason for the error
72 * if the transfer of the request is unsuccessful.
73 */
74 enum USB_Host_SendControlErrorCodes_t
75 {
76 HOST_SENDCONTROL_Successful = 0, /**< No error occurred in the request transfer. */
77 HOST_SENDCONTROL_DeviceDisconnect = 1, /**< The attached device was disconnected during the
78 * request transfer.
79 */
80 HOST_SENDCONTROL_PipeError = 2, /**< An error occured in the pipe while sending the request. */
81 HOST_SENDCONTROL_SetupStalled = 3, /**< The attached device stalled the request, usually
82 * indicating that the request is unsupported on the device.
83 */
84 HOST_SENDCONTROL_SoftwareTimeOut = 4, /**< The request or data transfer timed out. */
85 };
86
87 /* Global Variables: */
88 /** Global for the request to send via the USB_Host_SendControlRequest() function. This
89 * global should be filled with the correct control request data before sending the request to
90 * the attached device while in host mode.
91 */
92 extern USB_Host_Request_Header_t USB_HostRequest;
93
94 /* Function Prototypes: */
95 /** Sends the request stored in the USB_HostRequest global structure to the attached device,
96 * and transfers the data stored in the buffer to the device, or from the device to the buffer
97 * as requested.
98 *
99 * \param BufferPtr Pointer to the start of the data buffer if the request has a data stage, or
100 * NULL if the request transfers no data to or from the device.
101 *
102 * \return A value from the USB_Host_SendControlErrorCodes_t enum to indicate the result.
103 */
104 uint8_t USB_Host_SendControlRequest(void* BufferPtr);
105
106 /* Private Interface - For use in library only: */
107 #if !defined(__DOXYGEN__)
108 /* Enums: */
109 enum USB_WaitForTypes_t
110 {
111 USB_HOST_WAITFOR_SetupSent,
112 USB_HOST_WAITFOR_InReceived,
113 USB_HOST_WAITFOR_OutReady,
114 };
115
116 /* Function Prototypes: */
117 #if defined(INCLUDE_FROM_HOSTCHAPTER9_C)
118 static uint8_t USB_Host_Wait_For_Setup_IOS(const uint8_t WaitType);
119 #endif
120 #endif
121
122 /* Disable C linkage for C++ Compilers: */
123 #if defined(__cplusplus)
124 }
125 #endif
126
127 #endif