Fixed GenericHIDHost demo report write routine incorrect for control type requests...
[pub/USBasp.git] / LUFA / Drivers / USB / LowLevel / DevChapter9.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 device mode request processing. This module allows for the processing of standard control
34 * requests to the default control endpoint while in device mode.
35 *
36 * \see Chapter 9 of the USB 2.0 specification.
37 */
38
39 #ifndef __DEVCHAPTER9_H__
40 #define __DEVCHAPTER9_H__
41
42 /* Includes: */
43 #include <avr/io.h>
44 #include <avr/pgmspace.h>
45 #include <avr/eeprom.h>
46
47 #include "../HighLevel/StdDescriptors.h"
48 #include "../HighLevel/Events.h"
49 #include "../HighLevel/StdRequestType.h"
50 #include "LowLevel.h"
51
52 /* Enable C linkage for C++ Compilers: */
53 #if defined(__cplusplus)
54 extern "C" {
55 #endif
56
57 /* Public Interface - May be used in end-application: */
58 /* Global Variables: */
59 /** Indicates the currently set configuration number of the device. USB devices may have several
60 * different configurations which the host can select between; this indicates the currently selected
61 * value, or 0 if no configuration has been selected.
62 *
63 * If a device has only one single configuration, the token USE_SINGLE_DEVICE_CONFIGURATION may be
64 * defined in the project makefile and passed to the compiler using the -D switch. This optimize for
65 * a single configuration, saving a small amount of space in the resulting compiled binary.
66 *
67 * \note This variable should be treated as read-only in the user application, and never manually
68 * changed in value.
69 *
70 * \ingroup Group_Device
71 */
72 extern uint8_t USB_ConfigurationNumber;
73
74 /** Indicates if the host is currently allowing the device to issue remote wakeup events. If this
75 * flag is cleared, the device should not issue remote wakeup events to the host.
76 *
77 * \note This variable should be treated as read-only in the user application, and never manually
78 * changed in value.
79 *
80 * \ingroup Group_Device
81 */
82 extern bool USB_RemoteWakeupEnabled;
83
84 /** Indicates if the device is currently being powered by its own power supply, rather than being
85 * powered by the host's USB supply. This flag should remain cleared if the device does not
86 * support self powered mode, as indicated in the device descriptors.
87 *
88 * \ingroup Group_Device
89 */
90 extern bool USB_CurrentlySelfPowered;
91
92 /* Throwable Events: */
93 /** This module raises the USB_UnhandledControlPacket event when a request to the default control
94 * endpoint has been received, but the library does not implement an internal handler for it.
95 *
96 * \see Events.h for more information on this event.
97 */
98 RAISES_EVENT(USB_UnhandledControlPacket);
99
100 /** This module raises the USB_ConfigurationChanged event when the host issues a REQ_SetConfiguration
101 * device request, to change the currently selected configuration number.
102 *
103 * \see Events.h for more information on this event.
104 */
105 RAISES_EVENT(USB_ConfigurationChanged);
106
107 /** This module raises the USB_DeviceEnumerationComplete event when the host has completed its
108 * enumeration of the device (i.e. when a REQ_SetConfiguration request changes the current configuration
109 * number from 0 to a non-zero value).
110 *
111 * \see Events.h for more information on this event.
112 */
113 RAISES_EVENT(USB_DeviceEnumerationComplete);
114
115 /* Private Interface - For use in library only: */
116 #if !defined(__DOXYGEN__)
117 #if defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)
118 #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.
119 #endif
120
121 /* Function Prototypes: */
122 void USB_Device_ProcessControlPacket(void);
123
124 #if defined(INCLUDE_FROM_DEVCHAPTER9_C)
125 static void USB_Device_SetAddress(void);
126 static void USB_Device_SetConfiguration(void);
127 static void USB_Device_GetConfiguration(void);
128 static void USB_Device_GetDescriptor(void);
129 static void USB_Device_GetStatus(const uint8_t bmRequestType);
130 #if !defined(FEATURELESS_CONTROL_ONLY_DEVICE)
131 static void USB_Device_ClearSetFeature(const uint8_t bRequest, const uint8_t bmRequestType);
132 #endif
133 #endif
134 #endif
135
136 /* Disable C linkage for C++ Compilers: */
137 #if defined(__cplusplus)
138 }
139 #endif
140
141 #endif