Important update: Arm Announces End of Life Timeline for Mbed. This site will be archived in July 2026. Read the full announcement.
Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
Importing usb audio project into online Compiler

"a value of type "void *" cannot be used to initialize an entity of type "fnGPDMACbs_Type *"" in file "lpc17xx_gpdma.c/<a href="#" onClick="window.open('/cookbook/Compiler-Error-144');">144</a>"
Somebody get the USBDEV of the Examples above working will they
usb.h
/*---------------------------------------------------------------------------- * U S B - K e r n e l *---------------------------------------------------------------------------- * Name: usb.h * Purpose: USB Definitions * Version: V1.20 *---------------------------------------------------------------------------- * This software is supplied "AS IS" without any warranties, express, * implied or statutory, including but not limited to the implied * warranties of fitness for purpose, satisfactory quality and * noninfringement. Keil extends you a royalty-free right to reproduce * and distribute executable files created using this software for use * on NXP Semiconductors LPC family microcontroller devices only. Nothing * else gives you the right to use this software. * * Copyright (c) 2009 Keil - An ARM Company. All rights reserved. *---------------------------------------------------------------------------*/ #ifndef __USB_H__ #define __USB_H__ #include "lpc_types.h" #if defined ( __GNUC__ ) #define __packed __attribute__((__packed__)) #endif #if defined ( __CC_ARM ) typedef __packed union { #elif defined ( __GNUC__ ) typedef union __packed { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) typedef union { #endif uint16_t W; #if defined ( __CC_ARM ) __packed struct { #elif defined ( __GNUC__ ) struct __packed { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) struct { #endif uint8_t L; uint8_t H; } WB; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif } WORD_BYTE; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif /* bmRequestType.Dir */ #define REQUEST_HOST_TO_DEVICE 0 #define REQUEST_DEVICE_TO_HOST 1 /* bmRequestType.Type */ #define REQUEST_STANDARD 0 #define REQUEST_CLASS 1 #define REQUEST_VENDOR 2 #define REQUEST_RESERVED 3 /* bmRequestType.Recipient */ #define REQUEST_TO_DEVICE 0 #define REQUEST_TO_INTERFACE 1 #define REQUEST_TO_ENDPOINT 2 #define REQUEST_TO_OTHER 3 /* bmRequestType Definition */ #if defined ( __CC_ARM ) typedef __packed union _REQUEST_TYPE { #elif defined ( __GNUC__ ) typedef union __packed _REQUEST_TYPE { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) typedef union _REQUEST_TYPE { #endif #if defined ( __CC_ARM ) __packed struct _BM { #elif defined ( __GNUC__ ) struct __packed _BM { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) struct _BM { #endif uint8_t Recipient : 5; uint8_t Type : 2; uint8_t Dir : 1; } BM; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif uint8_t B; } REQUEST_TYPE; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif /* USB Standard Request Codes */ #define USB_REQUEST_GET_STATUS 0 #define USB_REQUEST_CLEAR_FEATURE 1 #define USB_REQUEST_SET_FEATURE 3 #define USB_REQUEST_SET_ADDRESS 5 #define USB_REQUEST_GET_DESCRIPTOR 6 #define USB_REQUEST_SET_DESCRIPTOR 7 #define USB_REQUEST_GET_CONFIGURATION 8 #define USB_REQUEST_SET_CONFIGURATION 9 #define USB_REQUEST_GET_INTERFACE 10 #define USB_REQUEST_SET_INTERFACE 11 #define USB_REQUEST_SYNC_FRAME 12 /* USB GET_STATUS Bit Values */ #define USB_GETSTATUS_SELF_POWERED 0x01 #define USB_GETSTATUS_REMOTE_WAKEUP 0x02 #define USB_GETSTATUS_ENDPOINT_STALL 0x01 /* USB Standard Feature selectors */ #define USB_FEATURE_ENDPOINT_STALL 0 #define USB_FEATURE_REMOTE_WAKEUP 1 /* USB Default Control Pipe Setup Packet */ #if defined ( __CC_ARM ) typedef __packed struct _USB_SETUP_PACKET { #elif defined ( __GNUC__ ) typedef struct __packed _USB_SETUP_PACKET { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) typedef struct _USB_SETUP_PACKET { #endif REQUEST_TYPE bmRequestType; uint8_t bRequest; WORD_BYTE wValue; WORD_BYTE wIndex; uint16_t wLength; } USB_SETUP_PACKET; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif /* USB Descriptor Types */ #define USB_DEVICE_DESCRIPTOR_TYPE 1 #define USB_CONFIGURATION_DESCRIPTOR_TYPE 2 #define USB_STRING_DESCRIPTOR_TYPE 3 #define USB_INTERFACE_DESCRIPTOR_TYPE 4 #define USB_ENDPOINT_DESCRIPTOR_TYPE 5 #define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE 6 #define USB_OTHER_SPEED_CONFIG_DESCRIPTOR_TYPE 7 #define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 8 #define USB_OTG_DESCRIPTOR_TYPE 9 #define USB_DEBUG_DESCRIPTOR_TYPE 10 #define USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE 11 /* USB Device Classes */ #define USB_DEVICE_CLASS_RESERVED 0x00 #define USB_DEVICE_CLASS_AUDIO 0x01 #define USB_DEVICE_CLASS_COMMUNICATIONS 0x02 #define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03 #define USB_DEVICE_CLASS_MONITOR 0x04 #define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05 #define USB_DEVICE_CLASS_POWER 0x06 #define USB_DEVICE_CLASS_PRINTER 0x07 #define USB_DEVICE_CLASS_STORAGE 0x08 #define USB_DEVICE_CLASS_HUB 0x09 #define USB_DEVICE_CLASS_MISCELLANEOUS 0xEF #define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF /* bmAttributes in Configuration Descriptor */ #define USB_CONFIG_POWERED_MASK 0x40 #define USB_CONFIG_BUS_POWERED 0x80 #define USB_CONFIG_SELF_POWERED 0xC0 #define USB_CONFIG_REMOTE_WAKEUP 0x20 /* bMaxPower in Configuration Descriptor */ #define USB_CONFIG_POWER_MA(mA) ((mA)/2) /* bEndpointAddress in Endpoint Descriptor */ #define USB_ENDPOINT_DIRECTION_MASK 0x80 #define USB_ENDPOINT_OUT(addr) ((addr) | 0x00) #define USB_ENDPOINT_IN(addr) ((addr) | 0x80) /* bmAttributes in Endpoint Descriptor */ #define USB_ENDPOINT_TYPE_MASK 0x03 #define USB_ENDPOINT_TYPE_CONTROL 0x00 #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01 #define USB_ENDPOINT_TYPE_BULK 0x02 #define USB_ENDPOINT_TYPE_INTERRUPT 0x03 #define USB_ENDPOINT_SYNC_MASK 0x0C #define USB_ENDPOINT_SYNC_NO_SYNCHRONIZATION 0x00 #define USB_ENDPOINT_SYNC_ASYNCHRONOUS 0x04 #define USB_ENDPOINT_SYNC_ADAPTIVE 0x08 #define USB_ENDPOINT_SYNC_SYNCHRONOUS 0x0C #define USB_ENDPOINT_USAGE_MASK 0x30 #define USB_ENDPOINT_USAGE_DATA 0x00 #define USB_ENDPOINT_USAGE_FEEDBACK 0x10 #define USB_ENDPOINT_USAGE_IMPLICIT_FEEDBACK 0x20 #define USB_ENDPOINT_USAGE_RESERVED 0x30 /* USB Standard Device Descriptor */ #if defined ( __CC_ARM ) typedef __packed struct _USB_DEVICE_DESCRIPTOR { #elif defined ( __GNUC__ ) typedef struct __packed _USB_DEVICE_DESCRIPTOR { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) typedef struct _USB_DEVICE_DESCRIPTOR { #endif uint8_t bLength; uint8_t bDescriptorType; uint16_t bcdUSB; uint8_t bDeviceClass; uint8_t bDeviceSubClass; uint8_t bDeviceProtocol; uint8_t bMaxPacketSize0; uint16_t idVendor; uint16_t idProduct; uint16_t bcdDevice; uint8_t iManufacturer; uint8_t iProduct; uint8_t iSerialNumber; uint8_t bNumConfigurations; } USB_DEVICE_DESCRIPTOR; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif /* USB 2.0 Device Qualifier Descriptor */ #if defined ( __CC_ARM ) typedef __packed struct _USB_DEVICE_QUALIFIER_DESCRIPTOR { #elif defined ( __GNUC__ ) typedef struct __packed _USB_DEVICE_QUALIFIER_DESCRIPTOR { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) typedef struct _USB_DEVICE_QUALIFIER_DESCRIPTOR { #endif uint8_t bLength; uint8_t bDescriptorType; uint16_t bcdUSB; uint8_t bDeviceClass; uint8_t bDeviceSubClass; uint8_t bDeviceProtocol; uint8_t bMaxPacketSize0; uint8_t bNumConfigurations; uint8_t bReserved; } USB_DEVICE_QUALIFIER_DESCRIPTOR; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif /* USB Standard Configuration Descriptor */ #if defined ( __CC_ARM ) typedef __packed struct _USB_CONFIGURATION_DESCRIPTOR { #elif defined ( __GNUC__ ) typedef struct __packed _USB_CONFIGURATION_DESCRIPTOR { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) typedef struct _USB_CONFIGURATION_DESCRIPTOR { #endif uint8_t bLength; uint8_t bDescriptorType; uint16_t wTotalLength; uint8_t bNumInterfaces; uint8_t bConfigurationValue; uint8_t iConfiguration; uint8_t bmAttributes; uint8_t bMaxPower; } USB_CONFIGURATION_DESCRIPTOR; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif /* USB Standard Interface Descriptor */ #if defined ( __CC_ARM ) typedef __packed struct _USB_INTERFACE_DESCRIPTOR { #elif defined ( __GNUC__ ) typedef struct __packed _USB_INTERFACE_DESCRIPTOR { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) typedef struct _USB_INTERFACE_DESCRIPTOR { #endif uint8_t bLength; uint8_t bDescriptorType; uint8_t bInterfaceNumber; uint8_t bAlternateSetting; uint8_t bNumEndpoints; uint8_t bInterfaceClass; uint8_t bInterfaceSubClass; uint8_t bInterfaceProtocol; uint8_t iInterface; } USB_INTERFACE_DESCRIPTOR; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif /* USB Standard Endpoint Descriptor */ #if defined ( __CC_ARM ) typedef __packed struct _USB_ENDPOINT_DESCRIPTOR { #elif defined ( __GNUC__ ) typedef struct __packed _USB_ENDPOINT_DESCRIPTOR { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) typedef struct _USB_ENDPOINT_DESCRIPTOR { #endif uint8_t bLength; uint8_t bDescriptorType; uint8_t bEndpointAddress; uint8_t bmAttributes; uint16_t wMaxPacketSize; uint8_t bInterval; } USB_ENDPOINT_DESCRIPTOR; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif /* USB String Descriptor */ #if defined ( __CC_ARM ) typedef __packed struct _USB_STRING_DESCRIPTOR { #elif defined ( __GNUC__ ) typedef struct __packed _USB_STRING_DESCRIPTOR { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) typedef struct _USB_STRING_DESCRIPTOR { #endif uint8_t bLength; uint8_t bDescriptorType; uint16_t bString/*[]*/; } USB_STRING_DESCRIPTOR; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif /* USB Common Descriptor */ #if defined ( __CC_ARM ) typedef __packed struct _USB_COMMON_DESCRIPTOR { #elif defined ( __GNUC__ ) typedef struct __packed _USB_COMMON_DESCRIPTOR { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) typedef struct _USB_COMMON_DESCRIPTOR { #endif uint8_t bLength; uint8_t bDescriptorType; } USB_COMMON_DESCRIPTOR; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif #endif /* __USB_H__ */
lpc_types.h
/***********************************************************************//** * @file lpc_types.h * @brief Contains the NXP ABL typedefs for C standard types. * It is intended to be used in ISO C conforming development * environments and checks for this insofar as it is possible * to do so. * @version 1.0 * @date 27 Jul. 2008 * @author wellsk ************************************************************************** * Software that is described herein is for illustrative purposes only * which provides customers with programming information regarding the * products. This software is supplied "AS IS" without any warranties. * NXP Semiconductors assumes no responsibility or liability for the * use of the software, conveys no license or title under any patent, * copyright, or mask work right to the product. NXP Semiconductors * reserves the right to make changes in the software without * notification. NXP Semiconductors also make no representation or * warranty that such application will be suitable for the specified * use without further testing or modification. **************************************************************************/ /* Type group ----------------------------------------------------------- */ /** @defgroup LPC_Types LPC_Types * @ingroup LPC1700CMSIS_FwLib_Drivers * @{ */ #ifndef LPC_TYPES_H #define LPC_TYPES_H /* Includes ------------------------------------------------------------------- */ #include <stdint.h> /* Public Types --------------------------------------------------------------- */ /** @defgroup LPC_Types_Public_Types LPC_Types Public Types * @{ */ /** * @brief Boolean Type definition */ typedef enum {FALSE = 0, TRUE = !FALSE} Bool; /** * @brief Flag Status and Interrupt Flag Status type definition */ typedef enum {RESET = 0, SET = !RESET} FlagStatus, IntStatus, SetState; #define PARAM_SETSTATE(State) ((State==RESET) || (State==SET)) /** * @brief Functional State Definition */ typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState; #define PARAM_FUNCTIONALSTATE(State) ((State==DISABLE) || (State==ENABLE)) /** * @ Status type definition */ typedef enum {ERROR = 0, SUCCESS = !ERROR} Status; /** * Read/Write transfer type mode (Block or non-block) */ typedef enum { NONE_BLOCKING = 0, /**< None Blocking type */ BLOCKING, /**< Blocking type */ } TRANSFER_BLOCK_Type; /** Pointer to Function returning Void (any number of parameters) */ typedef void (*PFV)(); /** Pointer to Function returning int32_t (any number of parameters) */ typedef int32_t(*PFI)(); /** * @} */ /* Public Macros -------------------------------------------------------------- */ /** @defgroup LPC_Types_Public_Macros LPC_Types Public Macros * @{ */ /* _BIT(n) sets the bit at position "n" * _BIT(n) is intended to be used in "OR" and "AND" expressions: * e.g., "(_BIT(3) | _BIT(7))". */ #undef _BIT /* Set bit macro */ #define _BIT(n) (1<<n) /* _SBF(f,v) sets the bit field starting at position "f" to value "v". * _SBF(f,v) is intended to be used in "OR" and "AND" expressions: * e.g., "((_SBF(5,7) | _SBF(12,0xF)) & 0xFFFF)" */ #undef _SBF /* Set bit field macro */ #define _SBF(f,v) (v<<f) /* _BITMASK constructs a symbol with 'field_width' least significant * bits set. * e.g., _BITMASK(5) constructs '0x1F', _BITMASK(16) == 0xFFFF * The symbol is intended to be used to limit the bit field width * thusly: * <a_register> = (any_expression) & _BITMASK(x), where 0 < x <= 32. * If "any_expression" results in a value that is larger than can be * contained in 'x' bits, the bits above 'x - 1' are masked off. When * used with the _SBF example above, the example would be written: * a_reg = ((_SBF(5,7) | _SBF(12,0xF)) & _BITMASK(16)) * This ensures that the value written to a_reg is no wider than * 16 bits, and makes the code easier to read and understand. */ #undef _BITMASK /* Bitmask creation macro */ #define _BITMASK(field_width) ( _BIT(field_width) - 1) /* NULL pointer */ #ifndef NULL #define NULL ((void*) 0) #endif /* Number of elements in an array */ #define NELEMENTS(array) (sizeof (array) / sizeof (array[0])) /* Static data/function define */ #define STATIC static /* External data/function define */ #define EXTERN extern #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #define MIN(a, b) (((a) < (b)) ? (a) : (b)) /** * @} */ /* Old Type Definition compatibility ------------------------------------------ */ /** @addtogroup LPC_Types_Public_Types LPC_Types Public Types * @{ */ /** SMA type for character type */ typedef char CHAR; /** SMA type for 8 bit unsigned value */ typedef uint8_t UNS_8; /** SMA type for 8 bit signed value */ typedef int8_t INT_8; /** SMA type for 16 bit unsigned value */ typedef uint16_t UNS_16; /** SMA type for 16 bit signed value */ typedef int16_t INT_16; /** SMA type for 32 bit unsigned value */ typedef uint32_t UNS_32; /** SMA type for 32 bit signed value */ typedef int32_t INT_32; /** SMA type for 64 bit signed value */ typedef int64_t INT_64; /** SMA type for 64 bit unsigned value */ typedef uint64_t UNS_64; /** 32 bit boolean type */ typedef Bool BOOL_32; /** 16 bit boolean type */ typedef Bool BOOL_16; /** 8 bit boolean type */ typedef Bool BOOL_8; /** * @} */ #endif /* LPC_TYPES_H */ /** * @} */ /* --------------------------------- End Of File ------------------------------ */
"the "packed" attribute is ignored in a typedef" in file "usb.h/" line 27 col 8
"attributes ignored here" in file "adcuser.c/"
"argument of type "void *" is incompatible with parameter of type "std::uint8_t *"" in file "usbcore.c/<a href="#" onClick="window.open('/cookbook/Compiler-Error-167');">167</a>"
The syntax conflict aswell:)?????????????????/
" Ignoring entry command. Cannot find argument 'Reset_Handler'." in file "/"
" Ignoring first command. Cannot find argument 'Reset_Handler'." in file "/"
What all this stuff I am getting now?
/*---------------------------------------------------------------------------- * U S B - K e r n e l *---------------------------------------------------------------------------- * Name: usbcore.c * Purpose: USB Core Module * Version: V1.20 *---------------------------------------------------------------------------- * This software is supplied "AS IS" without any warranties, express, * implied or statutory, including but not limited to the implied * warranties of fitness for purpose, satisfactory quality and * noninfringement. Keil extends you a royalty-free right to reproduce * and distribute executable files created using this software for use * on NXP Semiconductors LPC family microcontroller devices only. Nothing * else gives you the right to use this software. * * Copyright (c) 2009 Keil - An ARM Company. All rights reserved. *---------------------------------------------------------------------------- * History: * V1.20 Added vendor specific requests * Changed string descriptor handling * Reworked Endpoint0 * V1.00 Initial Version *----------------------------------------------------------------------------*/ #include "type.h" #include "usb.h" #include "usbcfg.h" #include "usbhw.h" #include "usbcore.h" #include "usbdesc.h" #include "usbuser.h" #if (USB_CLASS) #if (USB_AUDIO) #include "audio.h" #include "adcuser.h" #endif #if (USB_HID) #include "hid.h" #include "hiduser.h" #endif #if (USB_MSC) #include "msc.h" #include "mscuser.h" extern MSC_CSW CSW; #endif #if (USB_CDC) #include "cdc.h" #include "cdcuser.h" #endif #endif #if (USB_VENDOR) #include "vendor.h" #endif #pragma diag_suppress 111,177,1441 uint16_t USB_DeviceStatus; uint8_t USB_DeviceAddress; uint8_t USB_Configuration; uint32_t USB_EndPointMask; uint32_t USB_EndPointHalt; uint32_t USB_EndPointStall; /* EP must stay stalled */ uint8_t USB_NumInterfaces; uint8_t USB_AltSetting[USB_IF_NUM]; uint8_t EP0Buf[USB_MAX_PACKET0]; USB_EP_DATA EP0Data; USB_SETUP_PACKET SetupPacket; /* * Reset USB Core * Parameters: None * Return Value: None */ void USB_ResetCore (void) { USB_DeviceStatus = USB_POWER; USB_DeviceAddress = 0; USB_Configuration = 0; USB_EndPointMask = 0x00010001; USB_EndPointHalt = 0x00000000; USB_EndPointStall = 0x00000000; } /* * USB Request - Setup Stage * Parameters: None (global SetupPacket) * Return Value: None */ void USB_SetupStage (void) { USB_ReadEP(0x00, (uint8_t *)&SetupPacket); } /* * USB Request - Data In Stage * Parameters: None (global EP0Data) * Return Value: None */ void USB_DataInStage (void) { uint32_t cnt; if (EP0Data.Count > USB_MAX_PACKET0) { cnt = USB_MAX_PACKET0; } else { cnt = EP0Data.Count; } cnt = USB_WriteEP(0x80, EP0Data.pData, cnt); EP0Data.pData += cnt; EP0Data.Count -= cnt; } /* * USB Request - Data Out Stage * Parameters: None (global EP0Data) * Return Value: None */ void USB_DataOutStage (void) { uint32_t cnt; cnt = USB_ReadEP(0x00, EP0Data.pData); EP0Data.pData += cnt; EP0Data.Count -= cnt; } /* * USB Request - Status In Stage * Parameters: None * Return Value: None */ void USB_StatusInStage (void) { USB_WriteEP(0x80, NULL, 0); } /* * USB Request - Status Out Stage * Parameters: None * Return Value: None */ void USB_StatusOutStage (void) { USB_ReadEP(0x00, EP0Buf); } /* * Get Status USB Request * Parameters: None (global SetupPacket) * Return Value: TRUE - Success, FALSE - Error */ __inline uint32_t USB_ReqGetStatus (void) { uint32_t n, m; switch (SetupPacket.bmRequestType.BM.Recipient) { case REQUEST_TO_DEVICE: EP0Data.pData = (uint8_t *)&USB_DeviceStatus; break; case REQUEST_TO_INTERFACE: if ((USB_Configuration != 0) && (SetupPacket.wIndex.WB.L < USB_NumInterfaces)) { *((__packed uint16_t *)EP0Buf) = 0; EP0Data.pData = EP0Buf; } else { return (FALSE); } break; case REQUEST_TO_ENDPOINT: n = SetupPacket.wIndex.WB.L & 0x8F; m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n); if (((USB_Configuration != 0) || ((n & 0x0F) == 0)) && (USB_EndPointMask & m)) { *((__packed uint16_t *)EP0Buf) = (USB_EndPointHalt & m) ? 1 : 0; EP0Data.pData = EP0Buf; } else { return (FALSE); } break; default: return (FALSE); } return (TRUE); } /* * Set/Clear Feature USB Request * Parameters: sc: 0 - Clear, 1 - Set * (global SetupPacket) * Return Value: TRUE - Success, FALSE - Error */ __inline uint32_t USB_ReqSetClrFeature (uint32_t sc) { uint32_t n, m; switch (SetupPacket.bmRequestType.BM.Recipient) { case REQUEST_TO_DEVICE: if (SetupPacket.wValue.W == USB_FEATURE_REMOTE_WAKEUP) { if (sc) { USB_WakeUpCfg(TRUE); USB_DeviceStatus |= USB_GETSTATUS_REMOTE_WAKEUP; } else { USB_WakeUpCfg(FALSE); USB_DeviceStatus &= ~USB_GETSTATUS_REMOTE_WAKEUP; } } else { return (FALSE); } break; case REQUEST_TO_INTERFACE: return (FALSE); case REQUEST_TO_ENDPOINT: n = SetupPacket.wIndex.WB.L & 0x8F; m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n); if ((USB_Configuration != 0) && ((n & 0x0F) != 0) && (USB_EndPointMask & m)) { if (SetupPacket.wValue.W == USB_FEATURE_ENDPOINT_STALL) { if (sc) { USB_SetStallEP(n); USB_EndPointHalt |= m; } else { if ((USB_EndPointStall & m) != 0) { return (TRUE); } USB_ClrStallEP(n); #if (USB_MSC) if ((n == MSC_EP_IN) && ((USB_EndPointHalt & m) != 0)) { /* Compliance Test: rewrite CSW after unstall */ if (CSW.dSignature == MSC_CSW_Signature) { USB_WriteEP(MSC_EP_IN, (uint8_t *)&CSW, sizeof(CSW)); } } #endif USB_EndPointHalt &= ~m; } } else { return (FALSE); } } else { return (FALSE); } break; default: return (FALSE); } return (TRUE); } /* * Set Address USB Request * Parameters: None (global SetupPacket) * Return Value: TRUE - Success, FALSE - Error */ __inline uint32_t USB_ReqSetAddress (void) { switch (SetupPacket.bmRequestType.BM.Recipient) { case REQUEST_TO_DEVICE: USB_DeviceAddress = 0x80 | SetupPacket.wValue.WB.L; break; default: return (FALSE); } return (TRUE); } /* * Get Descriptor USB Request * Parameters: None (global SetupPacket) * Return Value: TRUE - Success, FALSE - Error */ __inline uint32_t USB_ReqGetDescriptor (void) { uint8_t *pD; uint32_t len, n; switch (SetupPacket.bmRequestType.BM.Recipient) { case REQUEST_TO_DEVICE: switch (SetupPacket.wValue.WB.H) { case USB_DEVICE_DESCRIPTOR_TYPE: EP0Data.pData = (uint8_t *)USB_DeviceDescriptor; len = USB_DEVICE_DESC_SIZE; break; case USB_CONFIGURATION_DESCRIPTOR_TYPE: pD = (uint8_t *)USB_ConfigDescriptor; for (n = 0; n != SetupPacket.wValue.WB.L; n++) { if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bLength != 0) { pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength; } } if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bLength == 0) { return (FALSE); } EP0Data.pData = pD; len = ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength; break; case USB_STRING_DESCRIPTOR_TYPE: pD = (uint8_t *)USB_StringDescriptor; for (n = 0; n != SetupPacket.wValue.WB.L; n++) { if (((USB_STRING_DESCRIPTOR *)pD)->bLength != 0) { pD += ((USB_STRING_DESCRIPTOR *)pD)->bLength; } } if (((USB_STRING_DESCRIPTOR *)pD)->bLength == 0) { return (FALSE); } EP0Data.pData = pD; len = ((USB_STRING_DESCRIPTOR *)EP0Data.pData)->bLength; break; default: return (FALSE); } break; case REQUEST_TO_INTERFACE: switch (SetupPacket.wValue.WB.H) { #if USB_HID case HID_HID_DESCRIPTOR_TYPE: if (SetupPacket.wIndex.WB.L != USB_HID_IF_NUM) { return (FALSE); /* Only Single HID Interface is supported */ } EP0Data.pData = (uint8_t *)USB_ConfigDescriptor + HID_DESC_OFFSET; len = HID_DESC_SIZE; break; case HID_REPORT_DESCRIPTOR_TYPE: if (SetupPacket.wIndex.WB.L != USB_HID_IF_NUM) { return (FALSE); /* Only Single HID Interface is supported */ } EP0Data.pData = (uint8_t *)HID_ReportDescriptor; len = HID_ReportDescSize; break; case HID_PHYSICAL_DESCRIPTOR_TYPE: return (FALSE); /* HID Physical Descriptor is not supported */ #endif default: return (FALSE); } break; default: return (FALSE); } if (EP0Data.Count > len) { EP0Data.Count = len; } return (TRUE); } /* * Get Configuration USB Request * Parameters: None (global SetupPacket) * Return Value: TRUE - Success, FALSE - Error */ __inline uint32_t USB_ReqGetConfiguration (void) { switch (SetupPacket.bmRequestType.BM.Recipient) { case REQUEST_TO_DEVICE: EP0Data.pData = &USB_Configuration; break; default: return (FALSE); } return (TRUE); } /* * Set Configuration USB Request * Parameters: None (global SetupPacket) * Return Value: TRUE - Success, FALSE - Error */ __inline uint32_t USB_ReqSetConfiguration (void) { USB_COMMON_DESCRIPTOR *pD; uint32_t alt = 0; uint32_t n, m; switch (SetupPacket.bmRequestType.BM.Recipient) { case REQUEST_TO_DEVICE: if (SetupPacket.wValue.WB.L) { pD = (USB_COMMON_DESCRIPTOR *)USB_ConfigDescriptor; while (pD->bLength) { switch (pD->bDescriptorType) { case USB_CONFIGURATION_DESCRIPTOR_TYPE: if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bConfigurationValue == SetupPacket.wValue.WB.L) { USB_Configuration = SetupPacket.wValue.WB.L; USB_NumInterfaces = ((USB_CONFIGURATION_DESCRIPTOR *)pD)->bNumInterfaces; for (n = 0; n < USB_IF_NUM; n++) { USB_AltSetting[n] = 0; } for (n = 1; n < 16; n++) { if (USB_EndPointMask & (1 << n)) { USB_DisableEP(n); } if (USB_EndPointMask & ((1 << 16) << n)) { USB_DisableEP(n | 0x80); } } USB_EndPointMask = 0x00010001; USB_EndPointHalt = 0x00000000; USB_EndPointStall= 0x00000000; USB_Configure(TRUE); if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bmAttributes & USB_CONFIG_POWERED_MASK) { USB_DeviceStatus |= USB_GETSTATUS_SELF_POWERED; } else { USB_DeviceStatus &= ~USB_GETSTATUS_SELF_POWERED; } } else { (uint8_t *)pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength; continue; } break; case USB_INTERFACE_DESCRIPTOR_TYPE: alt = ((USB_INTERFACE_DESCRIPTOR *)pD)->bAlternateSetting; break; case USB_ENDPOINT_DESCRIPTOR_TYPE: if (alt == 0) { n = ((USB_ENDPOINT_DESCRIPTOR *)pD)->bEndpointAddress & 0x8F; m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n); USB_EndPointMask |= m; USB_ConfigEP((USB_ENDPOINT_DESCRIPTOR *)pD); USB_EnableEP(n); USB_ResetEP(n); } break; } (uint8_t *)pD += pD->bLength; } } else { USB_Configuration = 0; for (n = 1; n < 16; n++) { if (USB_EndPointMask & (1 << n)) { USB_DisableEP(n); } if (USB_EndPointMask & ((1 << 16) << n)) { USB_DisableEP(n | 0x80); } } USB_EndPointMask = 0x00010001; USB_EndPointHalt = 0x00000000; USB_EndPointStall = 0x00000000; USB_Configure(FALSE); } if (USB_Configuration != SetupPacket.wValue.WB.L) { return (FALSE); } break; default: return (FALSE); } return (TRUE); } /* * Get Interface USB Request * Parameters: None (global SetupPacket) * Return Value: TRUE - Success, FALSE - Error */ __inline uint32_t USB_ReqGetInterface (void) { switch (SetupPacket.bmRequestType.BM.Recipient) { case REQUEST_TO_INTERFACE: if ((USB_Configuration != 0) && (SetupPacket.wIndex.WB.L < USB_NumInterfaces)) { EP0Data.pData = USB_AltSetting + SetupPacket.wIndex.WB.L; } else { return (FALSE); } break; default: return (FALSE); } return (TRUE); } /* * Set Interface USB Request * Parameters: None (global SetupPacket) * Return Value: TRUE - Success, FALSE - Error */ __inline uint32_t USB_ReqSetInterface (void) { USB_COMMON_DESCRIPTOR *pD; uint32_t ifn = 0, alt = 0, old = 0, msk = 0; uint32_t n, m; uint32_t set; switch (SetupPacket.bmRequestType.BM.Recipient) { case REQUEST_TO_INTERFACE: if (USB_Configuration == 0) return (FALSE); set = FALSE; pD = (USB_COMMON_DESCRIPTOR *)USB_ConfigDescriptor; while (pD->bLength) { switch (pD->bDescriptorType) { case USB_CONFIGURATION_DESCRIPTOR_TYPE: if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bConfigurationValue != USB_Configuration) { (uint8_t *)pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength; continue; } break; case USB_INTERFACE_DESCRIPTOR_TYPE: ifn = ((USB_INTERFACE_DESCRIPTOR *)pD)->bInterfaceNumber; alt = ((USB_INTERFACE_DESCRIPTOR *)pD)->bAlternateSetting; msk = 0; if ((ifn == SetupPacket.wIndex.WB.L) && (alt == SetupPacket.wValue.WB.L)) { set = TRUE; old = USB_AltSetting[ifn]; USB_AltSetting[ifn] = (uint8_t)alt; } break; case USB_ENDPOINT_DESCRIPTOR_TYPE: if (ifn == SetupPacket.wIndex.WB.L) { n = ((USB_ENDPOINT_DESCRIPTOR *)pD)->bEndpointAddress & 0x8F; m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n); if (alt == SetupPacket.wValue.WB.L) { USB_EndPointMask |= m; USB_EndPointHalt &= ~m; USB_ConfigEP((USB_ENDPOINT_DESCRIPTOR *)pD); USB_EnableEP(n); USB_ResetEP(n); msk |= m; } else if ((alt == old) && ((msk & m) == 0)) { USB_EndPointMask &= ~m; USB_EndPointHalt &= ~m; USB_DisableEP(n); } } break; } (uint8_t *)pD += pD->bLength; } break; default: return (FALSE); } return (set); } /* * USB Endpoint 0 Event Callback * Parameters: event * Return Value: none */ void USB_EndPoint0 (uint32_t event) { switch (event) { case USB_EVT_SETUP: USB_SetupStage(); USB_DirCtrlEP(SetupPacket.bmRequestType.BM.Dir); EP0Data.Count = SetupPacket.wLength; /* Number of bytes to transfer */ switch (SetupPacket.bmRequestType.BM.Type) { case REQUEST_STANDARD: switch (SetupPacket.bRequest) { case USB_REQUEST_GET_STATUS: if (!USB_ReqGetStatus()) { goto stall_i; } USB_DataInStage(); break; case USB_REQUEST_CLEAR_FEATURE: if (!USB_ReqSetClrFeature(0)) { goto stall_i; } USB_StatusInStage(); #if USB_FEATURE_EVENT USB_Feature_Event(); #endif break; case USB_REQUEST_SET_FEATURE: if (!USB_ReqSetClrFeature(1)) { goto stall_i; } USB_StatusInStage(); #if USB_FEATURE_EVENT USB_Feature_Event(); #endif break; case USB_REQUEST_SET_ADDRESS: if (!USB_ReqSetAddress()) { goto stall_i; } USB_StatusInStage(); break; case USB_REQUEST_GET_DESCRIPTOR: if (!USB_ReqGetDescriptor()) { goto stall_i; } USB_DataInStage(); break; case USB_REQUEST_SET_DESCRIPTOR: /*stall_o:*/ USB_SetStallEP(0x00); /* not supported */ EP0Data.Count = 0; break; case USB_REQUEST_GET_CONFIGURATION: if (!USB_ReqGetConfiguration()) { goto stall_i; } USB_DataInStage(); break; case USB_REQUEST_SET_CONFIGURATION: if (!USB_ReqSetConfiguration()) { goto stall_i; } USB_StatusInStage(); #if USB_CONFIGURE_EVENT USB_Configure_Event(); #endif break; case USB_REQUEST_GET_INTERFACE: if (!USB_ReqGetInterface()) { goto stall_i; } USB_DataInStage(); break; case USB_REQUEST_SET_INTERFACE: if (!USB_ReqSetInterface()) { goto stall_i; } USB_StatusInStage(); #if USB_INTERFACE_EVENT USB_Interface_Event(); #endif break; default: goto stall_i; } break; /* end case REQUEST_STANDARD */ #if USB_CLASS case REQUEST_CLASS: switch (SetupPacket.bmRequestType.BM.Recipient) { case REQUEST_TO_DEVICE: goto stall_i; /* not supported */ case REQUEST_TO_INTERFACE: #if USB_HID if (SetupPacket.wIndex.WB.L == USB_HID_IF_NUM) { /* IF number correct? */ switch (SetupPacket.bRequest) { case HID_REQUEST_GET_REPORT: if (HID_GetReport()) { EP0Data.pData = EP0Buf; /* point to data to be sent */ USB_DataInStage(); /* send requested data */ goto setup_class_ok; } break; case HID_REQUEST_SET_REPORT: EP0Data.pData = EP0Buf; /* data to be received */ goto setup_class_ok; case HID_REQUEST_GET_IDLE: if (HID_GetIdle()) { EP0Data.pData = EP0Buf; /* point to data to be sent */ USB_DataInStage(); /* send requested data */ goto setup_class_ok; } break; case HID_REQUEST_SET_IDLE: if (HID_SetIdle()) { USB_StatusInStage(); /* send Acknowledge */ goto setup_class_ok; } break; case HID_REQUEST_GET_PROTOCOL: if (HID_GetProtocol()) { EP0Data.pData = EP0Buf; /* point to data to be sent */ USB_DataInStage(); /* send requested data */ goto setup_class_ok; } break; case HID_REQUEST_SET_PROTOCOL: if (HID_SetProtocol()) { USB_StatusInStage(); /* send Acknowledge */ goto setup_class_ok; } break; } } #endif /* USB_HID */ #if USB_MSC if (SetupPacket.wIndex.WB.L == USB_MSC_IF_NUM) { /* IF number correct? */ switch (SetupPacket.bRequest) { case MSC_REQUEST_RESET: if ((SetupPacket.wValue.W == 0) && /* RESET with invalid parameters -> STALL */ (SetupPacket.wLength == 0)) { if (MSC_Reset()) { USB_StatusInStage(); goto setup_class_ok; } } break; case MSC_REQUEST_GET_MAX_LUN: if ((SetupPacket.wValue.W == 0) && /* GET_MAX_LUN with invalid parameters -> STALL */ (SetupPacket.wLength == 1)) { if (MSC_GetMaxLUN()) { EP0Data.pData = EP0Buf; USB_DataInStage(); goto setup_class_ok; } } break; } } #endif /* USB_MSC */ #if USB_AUDIO if ((SetupPacket.wIndex.WB.L == USB_ADC_CIF_NUM) || /* IF number correct? */ (SetupPacket.wIndex.WB.L == USB_ADC_SIF1_NUM) || (SetupPacket.wIndex.WB.L == USB_ADC_SIF2_NUM)) { switch (SetupPacket.bRequest) { case AUDIO_REQUEST_GET_CUR: case AUDIO_REQUEST_GET_MIN: case AUDIO_REQUEST_GET_MAX: case AUDIO_REQUEST_GET_RES: if (ADC_IF_GetRequest()) { EP0Data.pData = EP0Buf; /* point to data to be sent */ USB_DataInStage(); /* send requested data */ goto setup_class_ok; } break; case AUDIO_REQUEST_SET_CUR: // case AUDIO_REQUEST_SET_MIN: // case AUDIO_REQUEST_SET_MAX: // case AUDIO_REQUEST_SET_RES: EP0Data.pData = EP0Buf; /* data to be received */ goto setup_class_ok; } } #endif /* USB_AUDIO */ #if USB_CDC if ((SetupPacket.wIndex.WB.L == USB_CDC_CIF_NUM) || /* IF number correct? */ (SetupPacket.wIndex.WB.L == USB_CDC_DIF_NUM)) { switch (SetupPacket.bRequest) { case CDC_SEND_ENCAPSULATED_COMMAND: EP0Data.pData = EP0Buf; /* data to be received, see USB_EVT_OUT */ goto setup_class_ok; case CDC_GET_ENCAPSULATED_RESPONSE: if (CDC_GetEncapsulatedResponse()) { EP0Data.pData = EP0Buf; /* point to data to be sent */ USB_DataInStage(); /* send requested data */ goto setup_class_ok; } break; case CDC_SET_COMM_FEATURE: EP0Data.pData = EP0Buf; /* data to be received, see USB_EVT_OUT */ goto setup_class_ok; case CDC_GET_COMM_FEATURE: if (CDC_GetCommFeature(SetupPacket.wValue.W)) { EP0Data.pData = EP0Buf; /* point to data to be sent */ USB_DataInStage(); /* send requested data */ goto setup_class_ok; } break; case CDC_CLEAR_COMM_FEATURE: if (CDC_ClearCommFeature(SetupPacket.wValue.W)) { USB_StatusInStage(); /* send Acknowledge */ goto setup_class_ok; } break; case CDC_SET_LINE_CODING: EP0Data.pData = EP0Buf; /* data to be received, see USB_EVT_OUT */ goto setup_class_ok; case CDC_GET_LINE_CODING: if (CDC_GetLineCoding()) { EP0Data.pData = EP0Buf; /* point to data to be sent */ USB_DataInStage(); /* send requested data */ goto setup_class_ok; } break; case CDC_SET_CONTROL_LINE_STATE: if (CDC_SetControlLineState(SetupPacket.wValue.W)) { USB_StatusInStage(); /* send Acknowledge */ goto setup_class_ok; } break; case CDC_SEND_BREAK: if (CDC_SendBreak(SetupPacket.wValue.W)) { USB_StatusInStage(); /* send Acknowledge */ goto setup_class_ok; } break; } } #endif /* USB_CDC */ goto stall_i; /* not supported */ /* end case REQUEST_TO_INTERFACE */ case REQUEST_TO_ENDPOINT: #if USB_AUDIO switch (SetupPacket.bRequest) { case AUDIO_REQUEST_GET_CUR: case AUDIO_REQUEST_GET_MIN: case AUDIO_REQUEST_GET_MAX: case AUDIO_REQUEST_GET_RES: if (ADC_EP_GetRequest()) { EP0Data.pData = EP0Buf; /* point to data to be sent */ USB_DataInStage(); /* send requested data */ goto setup_class_ok; } break; case AUDIO_REQUEST_SET_CUR: // case AUDIO_REQUEST_SET_MIN: // case AUDIO_REQUEST_SET_MAX: // case AUDIO_REQUEST_SET_RES: EP0Data.pData = EP0Buf; /* data to be received */ goto setup_class_ok; } #endif /* USB_AUDIO */ goto stall_i; /* end case REQUEST_TO_ENDPOINT */ default: goto stall_i; } setup_class_ok: /* request finished successfully */ break; /* end case REQUEST_CLASS */ #endif /* USB_CLASS */ #if USB_VENDOR case REQUEST_VENDOR: switch (SetupPacket.bmRequestType.BM.Recipient) { case REQUEST_TO_DEVICE: if (!USB_ReqVendorDev(TRUE)) { goto stall_i; /* not supported */ } break; case REQUEST_TO_INTERFACE: if (!USB_ReqVendorIF(TRUE)) { goto stall_i; /* not supported */ } break; case REQUEST_TO_ENDPOINT: if (!USB_ReqVendorEP(TRUE)) { goto stall_i; /* not supported */ } break; default: goto stall_i; } if (SetupPacket.wLength) { if (SetupPacket.bmRequestType.BM.Dir == REQUEST_DEVICE_TO_HOST) { USB_DataInStage(); } } else { USB_StatusInStage(); } break; /* end case REQUEST_VENDOR */ #endif /* USB_VENDOR */ default: stall_i: USB_SetStallEP(0x80); EP0Data.Count = 0; break; } break; /* end case USB_EVT_SETUP */ case USB_EVT_OUT: if (SetupPacket.bmRequestType.BM.Dir == REQUEST_HOST_TO_DEVICE) { if (EP0Data.Count) { /* still data to receive ? */ USB_DataOutStage(); /* receive data */ if (EP0Data.Count == 0) { /* data complete ? */ switch (SetupPacket.bmRequestType.BM.Type) { case REQUEST_STANDARD: goto stall_i; /* not supported */ #if (USB_CLASS) case REQUEST_CLASS: switch (SetupPacket.bmRequestType.BM.Recipient) { case REQUEST_TO_DEVICE: goto stall_i; /* not supported */ case REQUEST_TO_INTERFACE: #if USB_HID if (SetupPacket.wIndex.WB.L == USB_HID_IF_NUM) { /* IF number correct? */ switch (SetupPacket.bRequest) { case HID_REQUEST_SET_REPORT: if (HID_SetReport()) { USB_StatusInStage(); /* send Acknowledge */ goto out_class_ok; } break; } } #endif /* USB_HID */ #if USB_AUDIO if ((SetupPacket.wIndex.WB.L == USB_ADC_CIF_NUM) || /* IF number correct? */ (SetupPacket.wIndex.WB.L == USB_ADC_SIF1_NUM) || (SetupPacket.wIndex.WB.L == USB_ADC_SIF2_NUM)) { switch (SetupPacket.bRequest) { case AUDIO_REQUEST_SET_CUR: // case AUDIO_REQUEST_SET_MIN: // case AUDIO_REQUEST_SET_MAX: // case AUDIO_REQUEST_SET_RES: if (ADC_IF_SetRequest()) { USB_StatusInStage(); /* send Acknowledge */ goto out_class_ok; } break; } } #endif /* USB_AUDIO */ #if USB_CDC if ((SetupPacket.wIndex.WB.L == USB_CDC_CIF_NUM) || /* IF number correct? */ (SetupPacket.wIndex.WB.L == USB_CDC_DIF_NUM)) { switch (SetupPacket.bRequest) { case CDC_SEND_ENCAPSULATED_COMMAND: if (CDC_SendEncapsulatedCommand()) { USB_StatusInStage(); /* send Acknowledge */ goto out_class_ok; } break; case CDC_SET_COMM_FEATURE: if (CDC_SetCommFeature(SetupPacket.wValue.W)) { USB_StatusInStage(); /* send Acknowledge */ goto out_class_ok; } break; case CDC_SET_LINE_CODING: if (CDC_SetLineCoding()) { USB_StatusInStage(); /* send Acknowledge */ goto out_class_ok; } break; } } #endif /* USB_CDC */ goto stall_i; /* end case REQUEST_TO_INTERFACE */ case REQUEST_TO_ENDPOINT: #if USB_AUDIO switch (SetupPacket.bRequest) { case AUDIO_REQUEST_SET_CUR: // case AUDIO_REQUEST_SET_MIN: // case AUDIO_REQUEST_SET_MAX: // case AUDIO_REQUEST_SET_RES: if (ADC_EP_SetRequest()) { USB_StatusInStage(); /* send Acknowledge */ goto out_class_ok; } break; } #endif /* USB_AUDIO */ goto stall_i; /* end case REQUEST_TO_ENDPOINT */ default: goto stall_i; } out_class_ok: /* request finished successfully */ break; /* end case REQUEST_CLASS */ #endif /* USB_CLASS */ #if USB_VENDOR case REQUEST_VENDOR: switch (SetupPacket.bmRequestType.BM.Recipient) { case REQUEST_TO_DEVICE: if (!USB_ReqVendorDev(FALSE)) { goto stall_i; /* not supported */ } break; case REQUEST_TO_INTERFACE: if (!USB_ReqVendorIF(FALSE)) { goto stall_i; /* not supported */ } break; case REQUEST_TO_ENDPOINT: if (!USB_ReqVendorEP(FALSE)) { goto stall_i; /* not supported */ } break; default: goto stall_i; } USB_StatusInStage(); break; /* end case REQUEST_VENDOR */ #endif /* USB_VENDOR */ default: goto stall_i; } } } } else { USB_StatusOutStage(); /* receive Acknowledge */ } break; /* end case USB_EVT_OUT */ case USB_EVT_IN : if (SetupPacket.bmRequestType.BM.Dir == REQUEST_DEVICE_TO_HOST) { USB_DataInStage(); /* send data */ } else { if (USB_DeviceAddress & 0x80) { USB_DeviceAddress &= 0x7F; USB_SetAddress(USB_DeviceAddress); } } break; /* end case USB_EVT_IN */ case USB_EVT_OUT_STALL: USB_ClrStallEP(0x00); break; case USB_EVT_IN_STALL: USB_ClrStallEP(0x80); break; } }
/*---------------------------------------------------------------------------- * U S B - K e r n e l *---------------------------------------------------------------------------- * Name: usbuser.c * Purpose: USB Custom User Module * Version: V1.20 *---------------------------------------------------------------------------- * This software is supplied "AS IS" without any warranties, express, * implied or statutory, including but not limited to the implied * warranties of fitness for purpose, satisfactory quality and * noninfringement. Keil extends you a royalty-free right to reproduce * and distribute executable files created using this software for use * on NXP Semiconductors LPC family microcontroller devices only. Nothing * else gives you the right to use this software. * * Copyright (c) 2009 Keil - An ARM Company. All rights reserved. *---------------------------------------------------------------------------*/ #include "type.h" #include "usb.h" #include "usbcfg.h" #include "usbhw.h" #include "usbcore.h" #include "usbuser.h" #include "usbaudio.h" /* * USB Power Event Callback * Called automatically on USB Power Event * Parameter: power: On(TRUE)/Off(FALSE) */ #if USB_POWER_EVENT void USB_Power_Event (uint32_t power) { } #endif /* * USB Reset Event Callback * Called automatically on USB Reset Event */ #if USB_RESET_EVENT void USB_Reset_Event (void) { USB_ResetCore(); } #endif /* * USB Suspend Event Callback * Called automatically on USB Suspend Event */ #if USB_SUSPEND_EVENT void USB_Suspend_Event (void) { } #endif /* * USB Resume Event Callback * Called automatically on USB Resume Event */ #if USB_RESUME_EVENT void USB_Resume_Event (void) { } #endif /* * USB Remote Wakeup Event Callback * Called automatically on USB Remote Wakeup Event */ #if USB_WAKEUP_EVENT void USB_WakeUp_Event (void) { } #endif /* * USB Start of Frame Event Callback * Called automatically on USB Start of Frame Event */ #if USB_SOF_EVENT void USB_SOF_Event (void) { #if USB_DMA == 0 if (USB_ReadEP(0x03, (BYTE *)&DataBuf[DataIn])) { /* Data Available */ DataIn += P_S; /* Update Data In Index */ DataIn &= B_S - 1; /* Adjust Data In Index */ if (((DataIn - DataOut) & (B_S - 1)) == (B_S/2)) { DataRun = 1; /* Data Stream running */ } } else { /* No Data */ DataRun = 0; /* Data Stream not running */ DataOut = DataIn; /* Initialize Data Indexes */ } #endif } #endif /* * USB Error Event Callback * Called automatically on USB Error Event * Parameter: error: Error Code */ #if USB_ERROR_EVENT void USB_Error_Event (uint32_t error) { } #endif /* * USB Set Configuration Event Callback * Called automatically on USB Set Configuration Request */ #if USB_CONFIGURE_EVENT void USB_Configure_Event (void) { if (USB_Configuration) { /* Check if USB is configured */ /* add your code here */ } } #endif /* * USB Set Interface Event Callback * Called automatically on USB Set Interface Request */ #if USB_INTERFACE_EVENT void USB_Interface_Event (void) { } #endif /* * USB Set/Clear Feature Event Callback * Called automatically on USB Set/Clear Feature Request */ #if USB_FEATURE_EVENT void USB_Feature_Event (void) { } #endif #define P_EP(n) ((USB_EP_EVENT & (1 << (n))) ? USB_EndPoint##n : NULL) /* USB Endpoint Events Callback Pointers */ void (* const USB_P_EP[16]) (uint32_t event) = { P_EP(0), P_EP(1), P_EP(2), P_EP(3), P_EP(4), P_EP(5), P_EP(6), P_EP(7), P_EP(8), P_EP(9), P_EP(10), P_EP(11), P_EP(12), P_EP(13), P_EP(14), P_EP(15), }; /* * USB Endpoint 1 Event Callback * Called automatically on USB Endpoint 1 Event * Parameter: event */ void USB_EndPoint1 (uint32_t event) { } /* * USB Endpoint 2 Event Callback * Called automatically on USB Endpoint 2 Event * Parameter: event */ void USB_EndPoint2 (uint32_t event) { } /* * USB Endpoint 3 Event Callback * Called automatically on USB Endpoint 3 Event * Parameter: event */ void USB_EndPoint3 (uint32_t event) { #if USB_DMA USB_DMA_DESCRIPTOR DD; if (event & USB_EVT_OUT_DMA_EOT) { /* End of Transfer */ if (USB_DMA_BufAdr(0x03) != ((uint32_t)DataBuf + 2*DataIn)) { /* Data Available */ DataIn += P_C*P_S; /* Update Data In Index */ DataIn &= B_S - 1; /* Adjust Data In Index */ if (((DataIn - DataOut) & (B_S - 1)) == (B_S/2)) { DataRun = 1; /* Data Stream running */ } } else { /* No Data */ DataRun = 0; /* Data Stream not running */ DataOut = DataIn; /* Initialize Data Indexes */ } } if (event & (USB_EVT_OUT_DMA_EOT) | (USB_EVT_OUT_DMA_NDR)) { /* End of Transfer or New Descriptor Request */ DD.BufAdr = (uint32_t)DataBuf + 2*DataIn; /* DMA Buffer Address */ DD.BufLen = P_C; /* DMA Packet Count */ DD.MaxSize = 0; /* Must be 0 for Iso Transfer */ DD.InfoAdr = (uint32_t)InfoBuf; /* Packet Info Buffer Address */ DD.Cfg.Val = 0; /* Initial DMA Configuration */ DD.Cfg.Type.IsoEP = 1; /* Iso Endpoint */ USB_DMA_Setup (0x03, &DD); /* Setup DMA */ USB_DMA_Enable(0x03); /* Enable DMA */ } #else event = event; #endif } /* * USB Endpoint 4 Event Callback * Called automatically on USB Endpoint 4 Event * Parameter: event */ void USB_EndPoint4 (uint32_t event) { } /* * USB Endpoint 5 Event Callback * Called automatically on USB Endpoint 5 Event * Parameter: event */ void USB_EndPoint5 (uint32_t event) { } /* * USB Endpoint 6 Event Callback * Called automatically on USB Endpoint 6 Event * Parameter: event */ void USB_EndPoint6 (uint32_t event) { } /* * USB Endpoint 7 Event Callback * Called automatically on USB Endpoint 7 Event * Parameter: event */ void USB_EndPoint7 (uint32_t event) { } /* * USB Endpoint 8 Event Callback * Called automatically on USB Endpoint 8 Event * Parameter: event */ void USB_EndPoint8 (uint32_t event) { } /* * USB Endpoint 9 Event Callback * Called automatically on USB Endpoint 9 Event * Parameter: event */ void USB_EndPoint9 (uint32_t event) { } /* * USB Endpoint 10 Event Callback * Called automatically on USB Endpoint 10 Event * Parameter: event */ void USB_EndPoint10 (uint32_t event) { } /* * USB Endpoint 11 Event Callback * Called automatically on USB Endpoint 11 Event * Parameter: event */ void USB_EndPoint11 (uint32_t event) { } /* * USB Endpoint 12 Event Callback * Called automatically on USB Endpoint 12 Event * Parameter: event */ void USB_EndPoint12 (uint32_t event) { } /* * USB Endpoint 13 Event Callback * Called automatically on USB Endpoint 13 Event * Parameter: event */ void USB_EndPoint13 (uint32_t event) { } /* * USB Endpoint 14 Event Callback * Called automatically on USB Endpoint 14 Event * Parameter: event */ void USB_EndPoint14 (uint32_t event) { } /* * USB Endpoint 15 Event Callback * Called automatically on USB Endpoint 15 Event * Parameter: event */ void USB_EndPoint15 (uint32_t event) { }
"argument of type "void *" is incompatible with parameter of type "std::uint8_t *"" in file "usbcore.c/<a href="#" onClick="window.open('/cookbook/Compiler-Error-167');">167</a>"
"expression must be a modifiable lvalue" in file "usbcore.c/<a href="#" onClick="window.open('/cookbook/Compiler-Error-137');">137</a>"
"operand types are incompatible ("void (*)(std::uint32_t)" and "void *")" in file "usbuser.c/"
Like 23 errors
"a value of type "void *" cannot be used to initialize an entity of type "void (*const)(std::uint32_t)"" in file "usbuser.c/<a href="#" onClick="window.open('/cookbook/Compiler-Error-144');">144</a>"
"the "packed" attribute is ignored in a typedef" in file "usb.h/"
- if defined ( CC_ARM ) typedef packed union {
/*---------------------------------------------------------------------------- * U S B - K e r n e l *---------------------------------------------------------------------------- * Name: usb.h * Purpose: USB Definitions * Version: V1.20 *---------------------------------------------------------------------------- * This software is supplied "AS IS" without any warranties, express, * implied or statutory, including but not limited to the implied * warranties of fitness for purpose, satisfactory quality and * noninfringement. Keil extends you a royalty-free right to reproduce * and distribute executable files created using this software for use * on NXP Semiconductors LPC family microcontroller devices only. Nothing * else gives you the right to use this software. * * Copyright (c) 2009 Keil - An ARM Company. All rights reserved. *---------------------------------------------------------------------------*/ #ifndef __USB_H__ #define __USB_H__ #include "lpc_types.h" #if defined ( __GNUC__ ) #define __packed __attribute__((__packed__)) #endif #if defined ( __CC_ARM ) typedef __packed union { #elif defined ( __GNUC__ ) typedef union __packed { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) typedef union { #endif uint16_t W; #if defined ( __CC_ARM ) __packed struct { #elif defined ( __GNUC__ ) struct __packed { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) struct { #endif uint8_t L; uint8_t H; } WB; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif } WORD_BYTE; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif /* bmRequestType.Dir */ #define REQUEST_HOST_TO_DEVICE 0 #define REQUEST_DEVICE_TO_HOST 1 /* bmRequestType.Type */ #define REQUEST_STANDARD 0 #define REQUEST_CLASS 1 #define REQUEST_VENDOR 2 #define REQUEST_RESERVED 3 /* bmRequestType.Recipient */ #define REQUEST_TO_DEVICE 0 #define REQUEST_TO_INTERFACE 1 #define REQUEST_TO_ENDPOINT 2 #define REQUEST_TO_OTHER 3 /* bmRequestType Definition */ #if defined ( __CC_ARM ) typedef __packed union _REQUEST_TYPE { #elif defined ( __GNUC__ ) typedef union __packed _REQUEST_TYPE { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) typedef union _REQUEST_TYPE { #endif #if defined ( __CC_ARM ) __packed struct _BM { #elif defined ( __GNUC__ ) struct __packed _BM { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) struct _BM { #endif uint8_t Recipient : 5; uint8_t Type : 2; uint8_t Dir : 1; } BM; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif uint8_t B; } REQUEST_TYPE; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif /* USB Standard Request Codes */ #define USB_REQUEST_GET_STATUS 0 #define USB_REQUEST_CLEAR_FEATURE 1 #define USB_REQUEST_SET_FEATURE 3 #define USB_REQUEST_SET_ADDRESS 5 #define USB_REQUEST_GET_DESCRIPTOR 6 #define USB_REQUEST_SET_DESCRIPTOR 7 #define USB_REQUEST_GET_CONFIGURATION 8 #define USB_REQUEST_SET_CONFIGURATION 9 #define USB_REQUEST_GET_INTERFACE 10 #define USB_REQUEST_SET_INTERFACE 11 #define USB_REQUEST_SYNC_FRAME 12 /* USB GET_STATUS Bit Values */ #define USB_GETSTATUS_SELF_POWERED 0x01 #define USB_GETSTATUS_REMOTE_WAKEUP 0x02 #define USB_GETSTATUS_ENDPOINT_STALL 0x01 /* USB Standard Feature selectors */ #define USB_FEATURE_ENDPOINT_STALL 0 #define USB_FEATURE_REMOTE_WAKEUP 1 /* USB Default Control Pipe Setup Packet */ #if defined ( __CC_ARM ) typedef __packed struct _USB_SETUP_PACKET { #elif defined ( __GNUC__ ) typedef struct __packed _USB_SETUP_PACKET { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) typedef struct _USB_SETUP_PACKET { #endif REQUEST_TYPE bmRequestType; uint8_t bRequest; WORD_BYTE wValue; WORD_BYTE wIndex; uint16_t wLength; } USB_SETUP_PACKET; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif /* USB Descriptor Types */ #define USB_DEVICE_DESCRIPTOR_TYPE 1 #define USB_CONFIGURATION_DESCRIPTOR_TYPE 2 #define USB_STRING_DESCRIPTOR_TYPE 3 #define USB_INTERFACE_DESCRIPTOR_TYPE 4 #define USB_ENDPOINT_DESCRIPTOR_TYPE 5 #define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE 6 #define USB_OTHER_SPEED_CONFIG_DESCRIPTOR_TYPE 7 #define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 8 #define USB_OTG_DESCRIPTOR_TYPE 9 #define USB_DEBUG_DESCRIPTOR_TYPE 10 #define USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE 11 /* USB Device Classes */ #define USB_DEVICE_CLASS_RESERVED 0x00 #define USB_DEVICE_CLASS_AUDIO 0x01 #define USB_DEVICE_CLASS_COMMUNICATIONS 0x02 #define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03 #define USB_DEVICE_CLASS_MONITOR 0x04 #define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05 #define USB_DEVICE_CLASS_POWER 0x06 #define USB_DEVICE_CLASS_PRINTER 0x07 #define USB_DEVICE_CLASS_STORAGE 0x08 #define USB_DEVICE_CLASS_HUB 0x09 #define USB_DEVICE_CLASS_MISCELLANEOUS 0xEF #define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF /* bmAttributes in Configuration Descriptor */ #define USB_CONFIG_POWERED_MASK 0x40 #define USB_CONFIG_BUS_POWERED 0x80 #define USB_CONFIG_SELF_POWERED 0xC0 #define USB_CONFIG_REMOTE_WAKEUP 0x20 /* bMaxPower in Configuration Descriptor */ #define USB_CONFIG_POWER_MA(mA) ((mA)/2) /* bEndpointAddress in Endpoint Descriptor */ #define USB_ENDPOINT_DIRECTION_MASK 0x80 #define USB_ENDPOINT_OUT(addr) ((addr) | 0x00) #define USB_ENDPOINT_IN(addr) ((addr) | 0x80) /* bmAttributes in Endpoint Descriptor */ #define USB_ENDPOINT_TYPE_MASK 0x03 #define USB_ENDPOINT_TYPE_CONTROL 0x00 #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01 #define USB_ENDPOINT_TYPE_BULK 0x02 #define USB_ENDPOINT_TYPE_INTERRUPT 0x03 #define USB_ENDPOINT_SYNC_MASK 0x0C #define USB_ENDPOINT_SYNC_NO_SYNCHRONIZATION 0x00 #define USB_ENDPOINT_SYNC_ASYNCHRONOUS 0x04 #define USB_ENDPOINT_SYNC_ADAPTIVE 0x08 #define USB_ENDPOINT_SYNC_SYNCHRONOUS 0x0C #define USB_ENDPOINT_USAGE_MASK 0x30 #define USB_ENDPOINT_USAGE_DATA 0x00 #define USB_ENDPOINT_USAGE_FEEDBACK 0x10 #define USB_ENDPOINT_USAGE_IMPLICIT_FEEDBACK 0x20 #define USB_ENDPOINT_USAGE_RESERVED 0x30 /* USB Standard Device Descriptor */ #if defined ( __CC_ARM ) typedef __packed struct _USB_DEVICE_DESCRIPTOR { #elif defined ( __GNUC__ ) typedef struct __packed _USB_DEVICE_DESCRIPTOR { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) typedef struct _USB_DEVICE_DESCRIPTOR { #endif uint8_t bLength; uint8_t bDescriptorType; uint16_t bcdUSB; uint8_t bDeviceClass; uint8_t bDeviceSubClass; uint8_t bDeviceProtocol; uint8_t bMaxPacketSize0; uint16_t idVendor; uint16_t idProduct; uint16_t bcdDevice; uint8_t iManufacturer; uint8_t iProduct; uint8_t iSerialNumber; uint8_t bNumConfigurations; } USB_DEVICE_DESCRIPTOR; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif /* USB 2.0 Device Qualifier Descriptor */ #if defined ( __CC_ARM ) typedef __packed struct _USB_DEVICE_QUALIFIER_DESCRIPTOR { #elif defined ( __GNUC__ ) typedef struct __packed _USB_DEVICE_QUALIFIER_DESCRIPTOR { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) typedef struct _USB_DEVICE_QUALIFIER_DESCRIPTOR { #endif uint8_t bLength; uint8_t bDescriptorType; uint16_t bcdUSB; uint8_t bDeviceClass; uint8_t bDeviceSubClass; uint8_t bDeviceProtocol; uint8_t bMaxPacketSize0; uint8_t bNumConfigurations; uint8_t bReserved; } USB_DEVICE_QUALIFIER_DESCRIPTOR; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif /* USB Standard Configuration Descriptor */ #if defined ( __CC_ARM ) typedef __packed struct _USB_CONFIGURATION_DESCRIPTOR { #elif defined ( __GNUC__ ) typedef struct __packed _USB_CONFIGURATION_DESCRIPTOR { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) typedef struct _USB_CONFIGURATION_DESCRIPTOR { #endif uint8_t bLength; uint8_t bDescriptorType; uint16_t wTotalLength; uint8_t bNumInterfaces; uint8_t bConfigurationValue; uint8_t iConfiguration; uint8_t bmAttributes; uint8_t bMaxPower; } USB_CONFIGURATION_DESCRIPTOR; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif /* USB Standard Interface Descriptor */ #if defined ( __CC_ARM ) typedef __packed struct _USB_INTERFACE_DESCRIPTOR { #elif defined ( __GNUC__ ) typedef struct __packed _USB_INTERFACE_DESCRIPTOR { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) typedef struct _USB_INTERFACE_DESCRIPTOR { #endif uint8_t bLength; uint8_t bDescriptorType; uint8_t bInterfaceNumber; uint8_t bAlternateSetting; uint8_t bNumEndpoints; uint8_t bInterfaceClass; uint8_t bInterfaceSubClass; uint8_t bInterfaceProtocol; uint8_t iInterface; } USB_INTERFACE_DESCRIPTOR; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif /* USB Standard Endpoint Descriptor */ #if defined ( __CC_ARM ) typedef __packed struct _USB_ENDPOINT_DESCRIPTOR { #elif defined ( __GNUC__ ) typedef struct __packed _USB_ENDPOINT_DESCRIPTOR { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) typedef struct _USB_ENDPOINT_DESCRIPTOR { #endif uint8_t bLength; uint8_t bDescriptorType; uint8_t bEndpointAddress; uint8_t bmAttributes; uint16_t wMaxPacketSize; uint8_t bInterval; } USB_ENDPOINT_DESCRIPTOR; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif /* USB String Descriptor */ #if defined ( __CC_ARM ) typedef __packed struct _USB_STRING_DESCRIPTOR { #elif defined ( __GNUC__ ) typedef struct __packed _USB_STRING_DESCRIPTOR { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) typedef struct _USB_STRING_DESCRIPTOR { #endif uint8_t bLength; uint8_t bDescriptorType; uint16_t bString/*[]*/; } USB_STRING_DESCRIPTOR; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif /* USB Common Descriptor */ #if defined ( __CC_ARM ) typedef __packed struct _USB_COMMON_DESCRIPTOR { #elif defined ( __GNUC__ ) typedef struct __packed _USB_COMMON_DESCRIPTOR { #elif defined ( __IAR_SYSTEMS_ICC__ ) #pragma pack(1) typedef struct _USB_COMMON_DESCRIPTOR { #endif uint8_t bLength; uint8_t bDescriptorType; } USB_COMMON_DESCRIPTOR; #ifdef __IAR_SYSTEMS_ICC__ #pragma pack() #endif #endif /* __USB_H__ */
"attributes ignored here" in file "usbcore.c/"
if (((USB_Configuration != 0) || ((n & 0x0F) == 0)) && (USB_EndPointMask & m)) {
- ((packed uint16_t *)EP0Buf) = (USB_EndPointHalt & m) ? 1 : 0; EP0Data.pData = EP0Buf; } else { return (FALSE);
/* bmRequestType Definition */
- if defined ( CC_ARM ) typedef packed union _REQUEST_TYPE {
/*---------------------------------------------------------------------------- * U S B - K e r n e l *---------------------------------------------------------------------------- * Name: ADCUSER.C * Purpose: Audio Device Class Custom User Module * Version: V1.10 *---------------------------------------------------------------------------- * This software is supplied "AS IS" without any warranties, express, * implied or statutory, including but not limited to the implied * warranties of fitness for purpose, satisfactory quality and * noninfringement. Keil extends you a royalty-free right to reproduce * and distribute executable files created using this software for use * on NXP Semiconductors LPC family microcontroller devices only. Nothing * else gives you the right to use this software. * * Copyright (c) 2009 Keil - An ARM Company. All rights reserved. *---------------------------------------------------------------------------*/ #include "lpc_types.h" #include "usb.h" #include "audio.h" #include "usbcfg.h" #include "usbcore.h" #include "adcuser.h" #include "usbaudio.h" uint16_t VolCur = 0x0100; /* Volume Current Value */ const uint16_t VolMin = 0x0000; /* Volume Minimum Value */ const uint16_t VolMax = 0x0100; /* Volume Maximum Value */ const uint16_t VolRes = 0x0004; /* Volume Resolution */ /* * Audio Device Class Interface Get Request Callback * Called automatically on ADC Interface Get Request * Parameters: None (global SetupPacket and EP0Buf) * Return Value: TRUE - Success, FALSE - Error */ uint32_t ADC_IF_GetRequest (void) { /* Interface = SetupPacket.wIndex.WB.L; EntityID = SetupPacket.wIndex.WB.H; Request = SetupPacket.bRequest; Value = SetupPacket.wValue.W; ... */ if (SetupPacket.wIndex.W == 0x0200) { /* Feature Unit: Interface = 0, ID = 2 */ if (SetupPacket.wValue.WB.L == 0) { /* Master Channel */ switch (SetupPacket.wValue.WB.H) { case AUDIO_MUTE_CONTROL: switch (SetupPacket.bRequest) { case AUDIO_REQUEST_GET_CUR: EP0Buf[0] = Mute; return (TRUE); } break; case AUDIO_VOLUME_CONTROL: switch (SetupPacket.bRequest) { case AUDIO_REQUEST_GET_CUR: *((__packed uint16_t *)EP0Buf) = VolCur; return (TRUE); case AUDIO_REQUEST_GET_MIN: *((__packed uint16_t *)EP0Buf) = VolMin; return (TRUE); case AUDIO_REQUEST_GET_MAX: *((__packed uint16_t *)EP0Buf) = VolMax; return (TRUE); case AUDIO_REQUEST_GET_RES: *((__packed uint16_t *)EP0Buf) = VolRes; return (TRUE); } break; } } } return (FALSE); /* Not Supported */ } /* * Audio Device Class Interface Set Request Callback * Called automatically on ADC Interface Set Request * Parameters: None (global SetupPacket and EP0Buf) * Return Value: TRUE - Success, FALSE - Error */ uint32_t ADC_IF_SetRequest (void) { /* Interface = SetupPacket.wIndex.WB.L; EntityID = SetupPacket.wIndex.WB.H; Request = SetupPacket.bRequest; Value = SetupPacket.wValue.W; ... */ if (SetupPacket.wIndex.W == 0x0200) { /* Feature Unit: Interface = 0, ID = 2 */ if (SetupPacket.wValue.WB.L == 0) { /* Master Channel */ switch (SetupPacket.wValue.WB.H) { case AUDIO_MUTE_CONTROL: switch (SetupPacket.bRequest) { case AUDIO_REQUEST_SET_CUR: Mute = EP0Buf[0]; return (TRUE); } break; case AUDIO_VOLUME_CONTROL: switch (SetupPacket.bRequest) { case AUDIO_REQUEST_SET_CUR: VolCur = *((__packed uint16_t *)EP0Buf); return (TRUE); } break; } } } return (FALSE); /* Not Supported */ } /* * Audio Device Class EndPoint Get Request Callback * Called automatically on ADC EndPoint Get Request * Parameters: None (global SetupPacket and EP0Buf) * Return Value: TRUE - Success, FALSE - Error */ uint32_t ADC_EP_GetRequest (void) { /* EndPoint = SetupPacket.wIndex.WB.L; Request = SetupPacket.bRequest; Value = SetupPacket.wValue.W; ... */ return (FALSE); /* Not Supported */ } /* * Audio Device Class EndPoint Set Request Callback * Called automatically on ADC EndPoint Set Request * Parameters: None (global SetupPacket and EP0Buf) * Return Value: TRUE - Success, FALSE - Error */ uint32_t ADC_EP_SetRequest (void) { /* EndPoint = SetupPacket.wIndex.WB.L; Request = SetupPacket.bRequest; Value = SetupPacket.wValue.W; ... */ return (FALSE); /* Not Supported */ }
"attributes ignored here" in file "adcuser.c/"
- ((packed uint16_t *)EP0Buf) = VolCur;
/***********************************************************************//** * @file lpc_types.h * @brief Contains the NXP ABL typedefs for C standard types. * It is intended to be used in ISO C conforming development * environments and checks for this insofar as it is possible * to do so. * @version 1.0 * @date 27 Jul. 2008 * @author wellsk ************************************************************************** * Software that is described herein is for illustrative purposes only * which provides customers with programming information regarding the * products. This software is supplied "AS IS" without any warranties. * NXP Semiconductors assumes no responsibility or liability for the * use of the software, conveys no license or title under any patent, * copyright, or mask work right to the product. NXP Semiconductors * reserves the right to make changes in the software without * notification. NXP Semiconductors also make no representation or * warranty that such application will be suitable for the specified * use without further testing or modification. **************************************************************************/ /* Type group ----------------------------------------------------------- */ /** @defgroup LPC_Types LPC_Types * @ingroup LPC1700CMSIS_FwLib_Drivers * @{ */ #ifndef LPC_TYPES_H #define LPC_TYPES_H /* Includes ------------------------------------------------------------------- */ #include <stdint.h> /* Public Types --------------------------------------------------------------- */ /** @defgroup LPC_Types_Public_Types LPC_Types Public Types * @{ */ /** * @brief Boolean Type definition */ typedef enum {FALSE = 0, TRUE = !FALSE} Bool; /** * @brief Flag Status and Interrupt Flag Status type definition */ typedef enum {RESET = 0, SET = !RESET} FlagStatus, IntStatus, SetState; #define PARAM_SETSTATE(State) ((State==RESET) || (State==SET)) /** * @brief Functional State Definition */ typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState; #define PARAM_FUNCTIONALSTATE(State) ((State==DISABLE) || (State==ENABLE)) /** * @ Status type definition */ typedef enum {ERROR = 0, SUCCESS = !ERROR} Status; /** * Read/Write transfer type mode (Block or non-block) */ typedef enum { NONE_BLOCKING = 0, /**< None Blocking type */ BLOCKING, /**< Blocking type */ } TRANSFER_BLOCK_Type; /** Pointer to Function returning Void (any number of parameters) */ typedef void (*PFV)(); /** Pointer to Function returning int32_t (any number of parameters) */ typedef int32_t(*PFI)(); /** * @} */ /* Public Macros -------------------------------------------------------------- */ /** @defgroup LPC_Types_Public_Macros LPC_Types Public Macros * @{ */ /* _BIT(n) sets the bit at position "n" * _BIT(n) is intended to be used in "OR" and "AND" expressions: * e.g., "(_BIT(3) | _BIT(7))". */ #undef _BIT /* Set bit macro */ #define _BIT(n) (1<<n) /* _SBF(f,v) sets the bit field starting at position "f" to value "v". * _SBF(f,v) is intended to be used in "OR" and "AND" expressions: * e.g., "((_SBF(5,7) | _SBF(12,0xF)) & 0xFFFF)" */ #undef _SBF /* Set bit field macro */ #define _SBF(f,v) (v<<f) /* _BITMASK constructs a symbol with 'field_width' least significant * bits set. * e.g., _BITMASK(5) constructs '0x1F', _BITMASK(16) == 0xFFFF * The symbol is intended to be used to limit the bit field width * thusly: * <a_register> = (any_expression) & _BITMASK(x), where 0 < x <= 32. * If "any_expression" results in a value that is larger than can be * contained in 'x' bits, the bits above 'x - 1' are masked off. When * used with the _SBF example above, the example would be written: * a_reg = ((_SBF(5,7) | _SBF(12,0xF)) & _BITMASK(16)) * This ensures that the value written to a_reg is no wider than * 16 bits, and makes the code easier to read and understand. */ #undef _BITMASK /* Bitmask creation macro */ #define _BITMASK(field_width) ( _BIT(field_width) - 1) /* NULL pointer */ #ifndef NULL #define NULL ((void*) 0) #endif /* Number of elements in an array */ #define NELEMENTS(array) (sizeof (array) / sizeof (array[0])) /* Static data/function define */ #define STATIC static /* External data/function define */ #define EXTERN extern #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #define MIN(a, b) (((a) < (b)) ? (a) : (b)) /** * @} */ /* Old Type Definition compatibility ------------------------------------------ */ /** @addtogroup LPC_Types_Public_Types LPC_Types Public Types * @{ */ /** SMA type for character type */ typedef char CHAR; /** SMA type for 8 bit unsigned value */ typedef uint8_t UNS_8; /** SMA type for 8 bit signed value */ typedef int8_t INT_8; /** SMA type for 16 bit unsigned value */ typedef uint16_t UNS_16; /** SMA type for 16 bit signed value */ typedef int16_t INT_16; /** SMA type for 32 bit unsigned value */ typedef uint32_t UNS_32; /** SMA type for 32 bit signed value */ typedef int32_t INT_32; /** SMA type for 64 bit signed value */ typedef int64_t INT_64; /** SMA type for 64 bit unsigned value */ typedef uint64_t UNS_64; /** 32 bit boolean type */ typedef Bool BOOL_32; /** 16 bit boolean type */ typedef Bool BOOL_16; /** 8 bit boolean type */ typedef Bool BOOL_8; /** * @} */ #endif /* LPC_TYPES_H */ /** * @} */ /* --------------------------------- End Of File ------------------------------ */
/* bmRequestType Definition */
- if defined ( CC_ARM ) typedef packed union _REQUEST_TYPE {
"the "packed" attribute is ignored in a typedef" in file "usb.h/"
What is all this the Online Compiler is giving me
"the "packed" attribute is ignored in a typedef" in file "usb.h/"
Trying to publshed the usb reversing code with online compiler
the usb import has already being done for me but runing it to problems getting it work
as anybody got any of this stuff to work
http://mbed.org/users/frank26080115/programs/LPC1700CMSIS_Examples/lobvoi
http://mbed.org/users/frank26080115/programs/LPC1700CMSIS_Examples/lobvoi/docs/USBDEV_2USBAudio_2Abstract_8h_source.html