3 Copyright (C) Dean Camera, 2009.
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
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.
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
31 #ifndef __DEVCHAPTER9_H__
32 #define __DEVCHAPTER9_H__
36 #include <avr/pgmspace.h>
37 #include <avr/eeprom.h>
42 #include "../HighLevel/StdDescriptors.h"
43 #include "../HighLevel/Events.h"
44 #include "../HighLevel/StdRequestType.h"
45 #include "../HighLevel/USBTask.h"
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.
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.
57 /* Enable C linkage for C++ Compilers: */
58 #if defined(__cplusplus)
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.
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.
72 * \note This variable should be treated as read-only in the user application, and never manually
75 * \ingroup Group_Device
77 extern uint8_t USB_ConfigurationNumber
;
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.
82 * \note This variable should be treated as read-only in the user application, and never manually
85 * \ingroup Group_Device
87 extern bool USB_RemoteWakeupEnabled
;
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.
93 * \ingroup Group_Device
95 extern bool USB_CurrentlySelfPowered
;
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.
103 /* Function Prototypes: */
104 void USB_Device_ProcessControlPacket(void);
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);
116 /* Disable C linkage for C++ Compilers: */
117 #if defined(__cplusplus)