Statistics
| Branch: | Tag: | Revision:

root / LUFA / Drivers / USB / Core / DeviceStandardReq.h @ 978b99e5

History | View | Annotate | Download (6.31 KB)

1
/*
2
             LUFA Library
3
     Copyright (C) Dean Camera, 2011.
4

5
  dean [at] fourwalledcubicle [dot] com
6
           www.lufa-lib.org
7
*/
8

    
9
/*
10
  Copyright 2011  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
/** \file
32
 *  \brief USB device standard request management.
33
 *
34
 *  This file contains the function prototypes necessary for the processing of incoming standard control requests
35
 *  when the library is in USB device mode.
36
 *
37
 *  \note This file should not be included directly. It is automatically included as needed by the USB driver
38
 *        dispatch header located in LUFA/Drivers/USB/USB.h.
39
 */
40

    
41
#ifndef __DEVICESTDREQ_H__
42
#define __DEVICESTDREQ_H__
43

    
44
        /* Includes: */
45
                #include "../../../Common/Common.h"
46
                #include "USBMode.h"                
47
                #include "StdDescriptors.h"
48
                #include "Events.h"
49
                #include "StdRequestType.h"
50
                #include "USBTask.h"
51
                #include "USBController.h"
52

    
53
        /* Enable C linkage for C++ Compilers: */
54
                #if defined(__cplusplus)
55
                        extern "C" {
56
                #endif
57

    
58
        /* Preprocessor Checks: */
59
                #if !defined(__INCLUDE_FROM_USB_DRIVER)
60
                        #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
61
                #endif
62

    
63
        /* Public Interface - May be used in end-application: */
64
                /* Enums: */
65
                        #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) || defined(__DOXYGEN__)
66
                                /** Enum for the possible descriptor memory spaces, for the \c MemoryAddressSpace parameter of the
67
                                 *  \ref CALLBACK_USB_GetDescriptor() function. This can be used when none of the \c USE_*_DESCRIPTORS
68
                                 *  compile time options are used, to indicate in which memory space the descriptor is stored.
69
                                 *
70
                                 *  \ingroup Group_Device
71
                                 */
72
                                enum USB_DescriptorMemorySpaces_t
73
                                {
74
                                        #if defined(ARCH_HAS_FLASH_ADDRESS_SPACE) || defined(__DOXYGEN__)
75
                                        MEMSPACE_FLASH    = 0, /**< Indicates the requested descriptor is located in FLASH memory. */
76
                                        #endif
77
                                        #if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE) || defined(__DOXYGEN__)
78
                                        MEMSPACE_EEPROM   = 1, /**< Indicates the requested descriptor is located in EEPROM memory. */
79
                                        #endif
80
                                        MEMSPACE_RAM      = 2, /**< Indicates the requested descriptor is located in RAM memory. */
81
                                };
82
                        #endif
83

    
84
                /* Global Variables: */
85
                        /** Indicates the currently set configuration number of the device. USB devices may have several
86
                         *  different configurations which the host can select between; this indicates the currently selected
87
                         *  value, or 0 if no configuration has been selected.
88
                         *
89
                         *  \note This variable should be treated as read-only in the user application, and never manually
90
                         *        changed in value.
91
                         *
92
                         *  \ingroup Group_Device
93
                         */
94
                        extern uint8_t USB_Device_ConfigurationNumber;
95

    
96
                        #if !defined(NO_DEVICE_REMOTE_WAKEUP)
97
                                /** Indicates if the host is currently allowing the device to issue remote wakeup events. If this
98
                                 *  flag is cleared, the device should not issue remote wakeup events to the host.
99
                                 *
100
                                 *  \note This variable should be treated as read-only in the user application, and never manually
101
                                 *        changed in value.
102
                                 *        \n\n
103
                                 *
104
                                 *  \note To reduce FLASH usage of the compiled applications where Remote Wakeup is not supported,
105
                                 *        this global and the underlying management code can be disabled by defining the
106
                                 *        \c NO_DEVICE_REMOTE_WAKEUP token in the project makefile and passing it to the compiler via
107
                                 *        the -D switch.
108
                                 *
109
                                 *  \ingroup Group_Device
110
                                 */
111
                                extern bool USB_Device_RemoteWakeupEnabled;
112
                        #endif
113

    
114
                        #if !defined(NO_DEVICE_SELF_POWER)
115
                                /** Indicates if the device is currently being powered by its own power supply, rather than being
116
                                 *  powered by the host's USB supply. This flag should remain cleared if the device does not
117
                                 *  support self powered mode, as indicated in the device descriptors.
118
                                 *
119
                                 *  \ingroup Group_Device
120
                                 */
121
                                extern bool USB_Device_CurrentlySelfPowered;
122
                        #endif
123

    
124
        /* Private Interface - For use in library only: */
125
        #if !defined(__DOXYGEN__)
126
                #if defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)
127
                        #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.
128
                #elif defined(USE_RAM_DESCRIPTORS) && defined(USE_FLASH_DESCRIPTORS)
129
                        #error USE_RAM_DESCRIPTORS and USE_FLASH_DESCRIPTORS are mutually exclusive.
130
                #elif defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)
131
                        #error USE_FLASH_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.
132
                #elif defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS) && defined(USE_RAM_DESCRIPTORS)
133
                        #error Only one of the USE_*_DESCRIPTORS modes should be selected.
134
                #endif
135

    
136
                /* Function Prototypes: */
137
                        void USB_Device_ProcessControlRequest(void);
138

    
139
                        #if defined(__INCLUDE_FROM_DEVICESTDREQ_C)
140
                                static void USB_Device_SetAddress(void);
141
                                static void USB_Device_SetConfiguration(void);
142
                                static void USB_Device_GetConfiguration(void);
143
                                static void USB_Device_GetDescriptor(void);
144
                                static void USB_Device_GetStatus(void);
145
                                static void USB_Device_ClearSetFeature(void);
146

    
147
                                #if !defined(NO_INTERNAL_SERIAL) && (USE_INTERNAL_SERIAL != NO_DESCRIPTOR)
148
                                        static void USB_Device_GetInternalSerialDescriptor(void);
149
                                #endif
150
                        #endif
151
        #endif
152

    
153
        /* Disable C linkage for C++ Compilers: */
154
                #if defined(__cplusplus)
155
                        }
156
                #endif
157

    
158
#endif
159