Added USE_INTERNAL_SERIAL compile time option to automatically read out the internal...
[pub/lufa.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 #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 #include <stdlib.h>
40 #include <ctype.h>
41
42 #include "../HighLevel/StdDescriptors.h"
43 #include "../HighLevel/Events.h"
44 #include "../HighLevel/StdRequestType.h"
45 #include "../HighLevel/USBTask.h"
46 #include "LowLevel.h"
47
48 /* Preprocessor Checks: */
49 #if defined(USE_INTERNAL_SERIAL) && !(defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
50 #error USE_INTERNAL_SERIAL invalid, the selected AVR model does not contain unique serial bytes.
51 #endif
52
53 #if defined(USE_INTERNAL_SERIAL) && (USE_INTERNAL_SERIAL <= 1)
54 #error USE_INTERNAL_SERIAL must be defined to the string descriptor index chosen for the serial number descriptor.
55 #endif
56
57 /* Enable C linkage for C++ Compilers: */
58 #if defined(__cplusplus)
59 extern "C" {
60 #endif
61
62 /* Public Interface - May be used in end-application: */
63 /* Global Variables: */
64 /** Indicates the currently set configuration number of the device. USB devices may have several
65 * different configurations which the host can select between; this indicates the currently selected
66 * value, or 0 if no configuration has been selected.
67 *
68 * If a device has only one single configuration, the token USE_SINGLE_DEVICE_CONFIGURATION may be
69 * defined in the project makefile and passed to the compiler using the -D switch. This optimize for
70 * a single configuration, saving a small amount of space in the resulting compiled binary.
71 *
72 * \note This variable should be treated as read-only in the user application, and never manually
73 * changed in value.
74 *
75 * \ingroup Group_Device
76 */
77 extern uint8_t USB_ConfigurationNumber;
78
79 /** Indicates if the host is currently allowing the device to issue remote wakeup events. If this
80 * flag is cleared, the device should not issue remote wakeup events to the host.
81 *
82 * \note This variable should be treated as read-only in the user application, and never manually
83 * changed in value.
84 *
85 * \ingroup Group_Device
86 */
87 extern bool USB_RemoteWakeupEnabled;
88
89 /** Indicates if the device is currently being powered by its own power supply, rather than being
90 * powered by the host's USB supply. This flag should remain cleared if the device does not
91 * support self powered mode, as indicated in the device descriptors.
92 *
93 * \ingroup Group_Device
94 */
95 extern bool USB_CurrentlySelfPowered;
96
97 /* Private Interface - For use in library only: */
98 #if !defined(__DOXYGEN__)
99 #if defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)
100 #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.
101 #endif
102
103 /* Function Prototypes: */
104 void USB_Device_ProcessControlPacket(void);
105
106 #if defined(INCLUDE_FROM_DEVCHAPTER9_C)
107 static void USB_Device_SetAddress(void);
108 static void USB_Device_SetConfiguration(void);
109 static void USB_Device_GetConfiguration(void);
110 static void USB_Device_GetDescriptor(void);
111 static void USB_Device_GetStatus(void);
112 static void USB_Device_ClearSetFeature(void);
113 #endif
114 #endif
115
116 /* Disable C linkage for C++ Compilers: */
117 #if defined(__cplusplus)
118 }
119 #endif
120
121 #endif