LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ConfigDescriptor.h
Go to the documentation of this file.
1 /*
2  * @brief USB Configuration Descriptor definitions
3  *
4  * @note
5  * Copyright(C) NXP Semiconductors, 2012
6  * Copyright(C) Dean Camera, 2011, 2012
7  * All rights reserved.
8  *
9  * @par
10  * Software that is described herein is for illustrative purposes only
11  * which provides customers with programming information regarding the
12  * LPC products. This software is supplied "AS IS" without any warranties of
13  * any kind, and NXP Semiconductors and its licensor disclaim any and
14  * all warranties, express or implied, including all implied warranties of
15  * merchantability, fitness for a particular purpose and non-infringement of
16  * intellectual property rights. NXP Semiconductors assumes no responsibility
17  * or liability for the use of the software, conveys no license or rights under any
18  * patent, copyright, mask work right, or any other intellectual property rights in
19  * or to any products. NXP Semiconductors reserves the right to make changes
20  * in the software without notification. NXP Semiconductors also makes no
21  * representation or warranty that such application will be suitable for the
22  * specified use without further testing or modification.
23  *
24  * @par
25  * Permission to use, copy, modify, and distribute this software and its
26  * documentation is hereby granted, under NXP Semiconductors' and its
27  * licensor's relevant copyrights in the software, without fee, provided that it
28  * is used in conjunction with NXP Semiconductors microcontrollers. This
29  * copyright, permission, and disclaimer notice must appear in all copies of
30  * this code.
31  */
32 
44 #ifndef __CONFIGDESCRIPTOR_H__
45 #define __CONFIGDESCRIPTOR_H__
46 
47  /* Includes: */
48  #include "../../../Common/Common.h"
49  #include "USBMode.h"
50  #include "HostStandardReq.h"
51  #include "StdDescriptors.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 lpcroot/libraries/LPCUSBlib/Drivers/USB/USB.h instead.
61  #endif
62 
63  /* Public Interface - May be used in end-application: */
64  /* Macros: */
77  #define DESCRIPTOR_PCAST(DescriptorPtr, Type) ((Type*)(DescriptorPtr))
78 
91  #define DESCRIPTOR_CAST(DescriptorPtr, Type) (*DESCRIPTOR_PCAST(DescriptorPtr, Type))
92 
97  #define DESCRIPTOR_TYPE(DescriptorPtr) DESCRIPTOR_PCAST(DescriptorPtr, USB_Descriptor_Header_t)->Type
98 
100  #define DESCRIPTOR_SIZE(DescriptorPtr) DESCRIPTOR_PCAST(DescriptorPtr, USB_Descriptor_Header_t)->Size
101 
102  /* Type Defines: */
108  typedef uint8_t (* ConfigComparatorPtr_t)(void*);
109 
110  /* Enums: */
113  {
127  };
128 
131  {
135  };
136 
139  {
144  };
145 
146  /* Function Prototypes: */
159  uint8_t USB_Host_GetDeviceConfigDescriptor(const uint8_t corenum,
160  const uint8_t ConfigNumber,
161  uint16_t* const ConfigSizePtr,
162  void* const BufferPtr,
163  const uint16_t BufferSize) ATTR_NON_NULL_PTR_ARG(3) ATTR_NON_NULL_PTR_ARG(4);
164 
173  void USB_GetNextDescriptorOfType(uint16_t* const BytesRem,
174  void** const CurrConfigLoc,
175  const uint8_t Type)
177 
189  void USB_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem,
190  void** const CurrConfigLoc,
191  const uint8_t Type,
192  const uint8_t BeforeType)
193  ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
194 
205  void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem,
206  void** const CurrConfigLoc,
207  const uint8_t Type,
208  const uint8_t AfterType)
209  ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
210 
251  uint8_t USB_GetNextDescriptorComp(uint16_t* const BytesRem,
252  void** const CurrConfigLoc,
253  ConfigComparatorPtr_t const ComparatorRoutine);
254 
255  /* Inline Functions: */
262  static inline void USB_GetNextDescriptor(uint16_t* const BytesRem,
263  void** CurrConfigLoc) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
264  static inline void USB_GetNextDescriptor(uint16_t* const BytesRem,
265  void** CurrConfigLoc)
266  {
267  uint16_t CurrDescriptorSize = DESCRIPTOR_CAST(*CurrConfigLoc, USB_Descriptor_Header_t).Size;
268 
269  if (*BytesRem < CurrDescriptorSize)
270  CurrDescriptorSize = *BytesRem;
271 
272  *CurrConfigLoc = (void*)((uintptr_t)*CurrConfigLoc + CurrDescriptorSize);
273  *BytesRem -= CurrDescriptorSize;
274  }
275 
276  /* Disable C linkage for C++ Compilers: */
277  #if defined(__cplusplus)
278  }
279  #endif
280 
281 #endif
282