Added incomplete MIDIToneGenerator project.
[pub/USBasp.git] / LUFA / Drivers / USB / LowLevel / DevChapter9.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2010.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2010 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 #ifndef __DEVCHAPTER9_H__
32 #define __DEVCHAPTER9_H__
33
34 /* Includes: */
35 #include <avr/io.h>
36 #include <avr/pgmspace.h>
37 #include <avr/eeprom.h>
38 #include <avr/boot.h>
39
40 #include "../HighLevel/StdDescriptors.h"
41 #include "../HighLevel/Events.h"
42 #include "../HighLevel/StdRequestType.h"
43 #include "../HighLevel/USBTask.h"
44 #include "LowLevel.h"
45
46 /* Enable C linkage for C++ Compilers: */
47 #if defined(__cplusplus)
48 extern "C" {
49 #endif
50
51 /* Preprocessor Checks: */
52 #if !defined(__INCLUDE_FROM_USB_DRIVER)
53 #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
54 #endif
55
56 /* Public Interface - May be used in end-application: */
57 /* Macros: */
58 #if defined(USE_SINGLE_DEVICE_CONFIGURATION)
59 #define FIXED_NUM_CONFIGURATIONS 1
60 #endif
61
62 /* Enums: */
63 #if !defined(USE_FLASH_DESCRIPTORS) && !defined(USE_EEPROM_DESCRIPTORS) && !defined(USE_RAM_DESCRIPTORS)
64 /** Enum for the possible descriptor memory spaces, for the MemoryAddressSpace of the
65 * \ref CALLBACK_USB_GetDescriptor() function. This can be used when none of the USE_*_DESCRIPTORS
66 * compile time options are used, to indicate in which memory space the descriptor is stored.
67 *
68 * \ingroup Group_Device
69 */
70 enum USB_DescriptorMemorySpaces_t
71 {
72 MEMSPACE_FLASH = 0, /**< Indicates the requested descriptor is located in FLASH memory */
73 MEMSPACE_EEPROM = 1, /**< Indicates the requested descriptor is located in EEPROM memory */
74 MEMSPACE_RAM = 2, /**< Indicates the requested descriptor is located in RAM memory */
75 };
76 #endif
77
78 /* Global Variables: */
79 /** Indicates the currently set configuration number of the device. USB devices may have several
80 * different configurations which the host can select between; this indicates the currently selected
81 * value, or 0 if no configuration has been selected.
82 *
83 * \note This variable should be treated as read-only in the user application, and never manually
84 * changed in value.
85 *
86 * \ingroup Group_Device
87 */
88 extern uint8_t USB_ConfigurationNumber;
89
90 #if !defined(NO_DEVICE_REMOTE_WAKEUP)
91 /** Indicates if the host is currently allowing the device to issue remote wakeup events. If this
92 * flag is cleared, the device should not issue remote wakeup events to the host.
93 *
94 * \note This variable should be treated as read-only in the user application, and never manually
95 * changed in value.
96 *
97 * \note To reduce FLASH usage of the compiled applications where Remote Wakeup is not supported,
98 * this global and the underlying management code can be disabled by defining the
99 * NO_DEVICE_REMOTE_WAKEUP token in the project makefile and passing it to the compiler via
100 * the -D switch.
101 *
102 * \ingroup Group_Device
103 */
104 extern bool USB_RemoteWakeupEnabled;
105 #endif
106
107 #if !defined(NO_DEVICE_SELF_POWER)
108 /** Indicates if the device is currently being powered by its own power supply, rather than being
109 * powered by the host's USB supply. This flag should remain cleared if the device does not
110 * support self powered mode, as indicated in the device descriptors.
111 *
112 * \ingroup Group_Device
113 */
114 extern bool USB_CurrentlySelfPowered;
115 #endif
116
117 /* Private Interface - For use in library only: */
118 #if !defined(__DOXYGEN__)
119 #if defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)
120 #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.
121 #elif defined(USE_RAM_DESCRIPTORS) && defined(USE_FLASH_DESCRIPTORS)
122 #error USE_RAM_DESCRIPTORS and USE_FLASH_DESCRIPTORS are mutually exclusive.
123 #elif defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)
124 #error USE_FLASH_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.
125 #elif defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS) && defined(USE_RAM_DESCRIPTORS)
126 #error Only one of the USE_*_DESCRIPTORS modes should be selected.
127 #endif
128
129 /* Function Prototypes: */
130 void USB_Device_ProcessControlRequest(void);
131
132 #if defined(__INCLUDE_FROM_DEVCHAPTER9_C)
133 static void USB_Device_SetAddress(void);
134 static void USB_Device_SetConfiguration(void);
135 static void USB_Device_GetConfiguration(void);
136 static void USB_Device_GetDescriptor(void);
137 static void USB_Device_GetStatus(void);
138 static void USB_Device_ClearSetFeature(void);
139
140 #if !defined(NO_INTERNAL_SERIAL) && (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
141 static char USB_Device_NibbleToASCII(uint8_t Nibble) ATTR_ALWAYS_INLINE;
142 static void USB_Device_GetInternalSerialDescriptor(void);
143 #endif
144 #endif
145 #endif
146
147 /* Disable C linkage for C++ Compilers: */
148 #if defined(__cplusplus)
149 }
150 #endif
151
152 #endif