]> git.sur5r.net Git - freertos/blob
21f0a3c092b6b513dae450b4fd7917aa1e716767
[freertos] /
1 /*\r
2  * @brief USB device standard request management\r
3  *\r
4  * @note\r
5  * Copyright(C) NXP Semiconductors, 2012\r
6  * Copyright(C) Dean Camera, 2011, 2012\r
7  * All rights reserved.\r
8  *\r
9  * @par\r
10  * Software that is described herein is for illustrative purposes only\r
11  * which provides customers with programming information regarding the\r
12  * LPC products.  This software is supplied "AS IS" without any warranties of\r
13  * any kind, and NXP Semiconductors and its licensor disclaim any and\r
14  * all warranties, express or implied, including all implied warranties of\r
15  * merchantability, fitness for a particular purpose and non-infringement of\r
16  * intellectual property rights.  NXP Semiconductors assumes no responsibility\r
17  * or liability for the use of the software, conveys no license or rights under any\r
18  * patent, copyright, mask work right, or any other intellectual property rights in\r
19  * or to any products. NXP Semiconductors reserves the right to make changes\r
20  * in the software without notification. NXP Semiconductors also makes no\r
21  * representation or warranty that such application will be suitable for the\r
22  * specified use without further testing or modification.\r
23  *\r
24  * @par\r
25  * Permission to use, copy, modify, and distribute this software and its\r
26  * documentation is hereby granted, under NXP Semiconductors' and its\r
27  * licensor's relevant copyrights in the software, without fee, provided that it\r
28  * is used in conjunction with NXP Semiconductors microcontrollers.  This\r
29  * copyright, permission, and disclaimer notice must appear in all copies of\r
30  * this code.\r
31  */\r
32 \r
33 \r
34  \r
35 #ifndef __DEVICESTDREQ_H__\r
36 #define __DEVICESTDREQ_H__\r
37 \r
38         /* Includes: */\r
39                 #include "../../../Common/Common.h"\r
40                 #include "USBMode.h"            \r
41                 #include "StdDescriptors.h"\r
42                 #include "Events.h"\r
43                 #include "StdRequestType.h"\r
44                 #include "USBTask.h"\r
45                 #include "USBController.h"\r
46 \r
47         /* Enable C linkage for C++ Compilers: */\r
48                 #if defined(__cplusplus)\r
49                         extern "C" {\r
50                 #endif\r
51 \r
52         /* Preprocessor Checks: */\r
53                 #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
54                         #error Do not include this file directly. Include lpcroot/libraries/LPCUSBlib/Drivers/USB/USB.h instead.\r
55                 #endif\r
56 \r
57         /* Public Interface - May be used in end-application: */\r
58                 /* Enums: */\r
59                         #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) || defined(__DOXYGEN__)\r
60                                 /** Enum for the possible descriptor memory spaces, for the \c MemoryAddressSpace parameter of the\r
61                                  *  @ref CALLBACK_USB_GetDescriptor() function. This can be used when none of the \c USE_*_DESCRIPTORS\r
62                                  *  compile time options are used, to indicate in which memory space the descriptor is stored.\r
63                                  *\r
64                                  *  @ingroup Group_Device\r
65                                  */\r
66                                 enum USB_DescriptorMemorySpaces_t\r
67                                 {\r
68                                         #if defined(ARCH_HAS_FLASH_ADDRESS_SPACE) || defined(__DOXYGEN__)\r
69                                         MEMSPACE_FLASH    = 0, /**< Indicates the requested descriptor is located in FLASH memory. */\r
70                                         #endif\r
71                                         #if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE) || defined(__DOXYGEN__)\r
72                                         MEMSPACE_EEPROM   = 1, /**< Indicates the requested descriptor is located in EEPROM memory. */\r
73                                         #endif\r
74                                         MEMSPACE_RAM      = 2, /**< Indicates the requested descriptor is located in RAM memory. */\r
75                                 };\r
76                         #endif\r
77 \r
78                 /* Global Variables: */\r
79                         /** Indicates the currently set configuration number of the device. USB devices may have several\r
80                          *  different configurations which the host can select between; this indicates the currently selected\r
81                          *  value, or 0 if no configuration has been selected.\r
82                          *\r
83                          *  @note This variable should be treated as read-only in the user application, and never manually\r
84                          *        changed in value.\r
85                          *\r
86                          *  @ingroup Group_Device\r
87                          */\r
88                         extern uint8_t USB_Device_ConfigurationNumber;\r
89 \r
90                         #if !defined(NO_DEVICE_REMOTE_WAKEUP)\r
91                                 /** Indicates if the host is currently allowing the device to issue remote wakeup events. If this\r
92                                  *  flag is cleared, the device should not issue remote wakeup events to the host.\r
93                                  *\r
94                                  *  @note This variable should be treated as read-only in the user application, and never manually\r
95                                  *        changed in value.\r
96                                  *        \n\n\r
97                                  *\r
98                                  *  @note To reduce FLASH usage of the compiled applications where Remote Wakeup is not supported,\r
99                                  *        this global and the underlying management code can be disabled by defining the\r
100                                  *        \c NO_DEVICE_REMOTE_WAKEUP token in the project makefile and passing it to the compiler via\r
101                                  *        the -D switch.\r
102                                  *\r
103                                  *  @ingroup Group_Device\r
104                                  */\r
105                                 extern bool USB_Device_RemoteWakeupEnabled;\r
106                         #endif\r
107 \r
108                         #if !defined(NO_DEVICE_SELF_POWER)\r
109                                 /** Indicates if the device is currently being powered by its own power supply, rather than being\r
110                                  *  powered by the host's USB supply. This flag should remain cleared if the device does not\r
111                                  *  support self powered mode, as indicated in the device descriptors.\r
112                                  *\r
113                                  *  @ingroup Group_Device\r
114                                  */\r
115                                 extern bool USB_Device_CurrentlySelfPowered;\r
116                         #endif\r
117 \r
118         /* Private Interface - For use in library only: */\r
119         #if !defined(__DOXYGEN__)\r
120                 #if defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)\r
121                         #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.\r
122                 #elif defined(USE_RAM_DESCRIPTORS) && defined(USE_FLASH_DESCRIPTORS)\r
123                         #error USE_RAM_DESCRIPTORS and USE_FLASH_DESCRIPTORS are mutually exclusive.\r
124                 #elif defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)\r
125                         #error USE_FLASH_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.\r
126                 #elif defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS) && defined(USE_RAM_DESCRIPTORS)\r
127                         #error Only one of the USE_*_DESCRIPTORS modes should be selected.\r
128                 #endif\r
129 \r
130                 /* Function Prototypes: */\r
131                         void USB_Device_ProcessControlRequest(uint8_t corenum);\r
132 \r
133                         #if defined(__INCLUDE_FROM_DEVICESTDREQ_C)\r
134                                 static void USB_Device_SetAddress(uint8_t corenum);\r
135                                 static void USB_Device_SetConfiguration(uint8_t corenum);\r
136                                 static void USB_Device_GetConfiguration(uint8_t corenum);\r
137                                 static void USB_Device_GetDescriptor(uint8_t corenum);\r
138                                 static void USB_Device_GetStatus(uint8_t corenum);\r
139                                 static void USB_Device_ClearSetFeature(uint8_t corenum);\r
140 \r
141                                 #if !defined(NO_INTERNAL_SERIAL) && (USE_INTERNAL_SERIAL != NO_DESCRIPTOR)\r
142                                         static void USB_Device_GetInternalSerialDescriptor(uint8_t corenum);\r
143                                 #endif\r
144                         #endif\r
145         #endif\r
146 \r
147         /* Disable C linkage for C++ Compilers: */\r
148                 #if defined(__cplusplus)\r
149                         }\r
150                 #endif\r
151 \r
152 #endif\r
153 \r