From ea7c87e5e79db7103f886d8c7d1deaad6b1c0fe0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20Schm=C3=B6lzer?= Date: Wed, 31 Aug 2011 00:20:35 +0200 Subject: [PATCH] ULINK driver: Remove typedefs in OpenULINK firmware USB descriptor structures MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Schmölzer --- src/jtag/drivers/OpenULINK/include/usb.h | 34 ++++++++--------- src/jtag/drivers/OpenULINK/src/usb.c | 48 ++++++++++++++---------- 2 files changed, 45 insertions(+), 37 deletions(-) diff --git a/src/jtag/drivers/OpenULINK/include/usb.h b/src/jtag/drivers/OpenULINK/include/usb.h index f70819ea..a507c9e4 100644 --- a/src/jtag/drivers/OpenULINK/include/usb.h +++ b/src/jtag/drivers/OpenULINK/include/usb.h @@ -48,7 +48,7 @@ #define STR_DESCR(len,...) { len*2+2, DESCRIPTOR_TYPE_STRING, { __VA_ARGS__ } } /** USB Device Descriptor. See USB 1.1 spec, pp. 196 - 198 */ -typedef struct { +struct usb_device_descriptor { u8 bLength; ///< Size of this descriptor in bytes. u8 bDescriptorType; ///< DEVICE Descriptor Type. u16 bcdUSB; ///< USB specification release number (BCD). @@ -63,10 +63,10 @@ typedef struct { u8 iProduct; ///< Index of product string descriptor. u8 iSerialNumber; ///< Index of string descriptor containing serial #. u8 bNumConfigurations; ///< Number of possible configurations. -} usb_device_descriptor_t; +}; /** USB Configuration Descriptor. See USB 1.1 spec, pp. 199 - 200 */ -typedef struct { +struct usb_config_descriptor { u8 bLength; ///< Size of this descriptor in bytes. u8 bDescriptorType; ///< CONFIGURATION descriptor type. u16 wTotalLength; ///< Combined total length of all descriptors. @@ -75,10 +75,10 @@ typedef struct { u8 iConfiguration; ///< Index of configuration string descriptor. u8 bmAttributes; ///< Configuration characteristics. u8 MaxPower; ///< Maximum power consumption in 2 mA units. -} usb_config_descriptor_t; +}; /** USB Interface Descriptor. See USB 1.1 spec, pp. 201 - 203 */ -typedef struct { +struct usb_interface_descriptor { u8 bLength; ///< Size of this descriptor in bytes. u8 bDescriptorType; ///< INTERFACE descriptor type. u8 bInterfaceNumber; ///< Interface number. @@ -88,48 +88,48 @@ typedef struct { u8 bInterfaceSubclass; ///< Subclass code. u8 bInterfaceProtocol; ///< Protocol code. u8 iInterface; ///< Index of interface string descriptor. -} usb_interface_descriptor_t; +}; /** USB Endpoint Descriptor. See USB 1.1 spec, pp. 203 - 204 */ -typedef struct { +struct usb_endpoint_descriptor { u8 bLength; ///< Size of this descriptor in bytes. u8 bDescriptorType; ///< ENDPOINT descriptor type. u8 bEndpointAddress; ///< Endpoint Address: USB 1.1 spec, table 9-10. u8 bmAttributes; ///< Endpoint Attributes: USB 1.1 spec, table 9-10. u16 wMaxPacketSize; ///< Maximum packet size for this endpoint. u8 bInterval; ///< Polling interval (in ms) for this endpoint. -} usb_endpoint_descriptor_t; +}; /** USB Language Descriptor. See USB 1.1 spec, pp. 204 - 205 */ -typedef struct { +struct usb_language_descriptor { u8 bLength; ///< Size of this descriptor in bytes. u8 bDescriptorType; ///< STRING descriptor type. u16 wLANGID[]; ///< LANGID codes. -} usb_language_descriptor_t; +}; /** USB String Descriptor. See USB 1.1 spec, pp. 204 - 205 */ -typedef struct { +struct usb_string_descriptor { u8 bLength; ///< Size of this descriptor in bytes. u8 bDescriptorType; ///< STRING descriptor type. u16 bString[]; ///< UNICODE encoded string. -} usb_string_descriptor_t; +}; /********************** USB Control Endpoint 0 related *********************/ /** USB Control Setup Data. See USB 1.1 spec, pp. 183 - 185 */ -typedef struct { +struct setup_data { u8 bmRequestType; ///< Characteristics of a request. u8 bRequest; ///< Specific request. u16 wValue; ///< Field that varies according to request. u16 wIndex; ///< Field that varies according to request. u16 wLength; ///< Number of bytes to transfer in data stage. -} setup_data_t; +}; /* External declarations for variables that need to be accessed outside of * the USB module */ extern volatile bool EP2_out; extern volatile bool EP2_in; -extern volatile __xdata __at 0x7FE8 setup_data_t setup_data; +extern volatile __xdata __at 0x7FE8 struct setup_data setup_data; /* * USB Request Types (bmRequestType): See USB 1.1 spec, page 183, table 9-2 @@ -225,7 +225,7 @@ extern volatile __xdata __at 0x7FE8 setup_data_t setup_data; /************************** EZ-USB specific stuff **************************/ /** USB Interrupts. See AN2131-TRM, page 9-4 for details */ -typedef enum { +enum usb_isr { SUDAV_ISR = 13, SOF_ISR, SUTOK_ISR, @@ -248,7 +248,7 @@ typedef enum { EP6OUT_ISR, EP7IN_ISR, EP7OUT_ISR -} USB_ISR; +}; /*************************** Function Prototypes ***************************/ diff --git a/src/jtag/drivers/OpenULINK/src/usb.c b/src/jtag/drivers/OpenULINK/src/usb.c index 042addf6..aa001f9f 100644 --- a/src/jtag/drivers/OpenULINK/src/usb.c +++ b/src/jtag/drivers/OpenULINK/src/usb.c @@ -36,7 +36,7 @@ volatile bool EP2_out = 0; volatile bool EP2_in = 0; -volatile __xdata __at 0x7FE8 setup_data_t setup_data; +volatile __xdata __at 0x7FE8 struct setup_data setup_data; /* Define number of endpoints (except Control Endpoint 0) in a central place. * Be sure to include the neccessary endpoint descriptors! */ @@ -56,8 +56,8 @@ volatile __xdata __at 0x7FE8 setup_data_t setup_data; * old-fashioned way... */ -__code usb_device_descriptor_t device_descriptor = { - /* .bLength = */ sizeof(usb_device_descriptor_t), +__code struct usb_device_descriptor device_descriptor = { + /* .bLength = */ sizeof(struct usb_device_descriptor), /* .bDescriptorType = */ DESCRIPTOR_TYPE_DEVICE, /* .bcdUSB = */ 0x0110, /* BCD: 01.00 (Version 1.0 USB spec) */ /* .bDeviceClass = */ 0xFF, /* 0xFF = vendor-specific */ @@ -75,12 +75,13 @@ __code usb_device_descriptor_t device_descriptor = { /* WARNING: ALL config, interface and endpoint descriptors MUST be adjacent! */ -__code usb_config_descriptor_t config_descriptor = { - /* .bLength = */ sizeof(usb_config_descriptor_t), +__code struct usb_config_descriptor config_descriptor = { + /* .bLength = */ sizeof(struct usb_config_descriptor), /* .bDescriptorType = */ DESCRIPTOR_TYPE_CONFIGURATION, - /* .wTotalLength = */ sizeof(usb_config_descriptor_t) + - sizeof(usb_interface_descriptor_t) + - NUM_ENDPOINTS * sizeof(usb_endpoint_descriptor_t), + /* .wTotalLength = */ sizeof(struct usb_config_descriptor) + + sizeof(struct usb_interface_descriptor) + + (NUM_ENDPOINTS * + sizeof(struct usb_endpoint_descriptor)), /* .bNumInterfaces = */ 1, /* .bConfigurationValue = */ 1, /* .iConfiguration = */ 4, /* String describing this configuration */ @@ -88,8 +89,8 @@ __code usb_config_descriptor_t config_descriptor = { /* .MaxPower = */ 50 /* 100 mA */ }; -__code usb_interface_descriptor_t interface_descriptor00 = { - /* .bLength = */ sizeof(usb_interface_descriptor_t), +__code struct usb_interface_descriptor interface_descriptor00 = { + /* .bLength = */ sizeof(struct usb_interface_descriptor), /* .bDescriptorType = */ DESCRIPTOR_TYPE_INTERFACE, /* .bInterfaceNumber = */ 0, /* .bAlternateSetting = */ 0, @@ -100,8 +101,8 @@ __code usb_interface_descriptor_t interface_descriptor00 = { /* .iInterface = */ 0 }; -__code usb_endpoint_descriptor_t Bulk_EP2_IN_Endpoint_Descriptor = { - /* .bLength = */ sizeof(usb_endpoint_descriptor_t), +__code struct usb_endpoint_descriptor Bulk_EP2_IN_Endpoint_Descriptor = { + /* .bLength = */ sizeof(struct usb_endpoint_descriptor), /* .bDescriptorType = */ 0x05, /* .bEndpointAddress = */ 2 | USB_DIR_IN, /* .bmAttributes = */ 0x02, @@ -109,8 +110,8 @@ __code usb_endpoint_descriptor_t Bulk_EP2_IN_Endpoint_Descriptor = { /* .bInterval = */ 0 }; -__code usb_endpoint_descriptor_t Bulk_EP2_OUT_Endpoint_Descriptor = { - /* .bLength = */ sizeof(usb_endpoint_descriptor_t), +__code struct usb_endpoint_descriptor Bulk_EP2_OUT_Endpoint_Descriptor = { + /* .bLength = */ sizeof(struct usb_endpoint_descriptor), /* .bDescriptorType = */ 0x05, /* .bEndpointAddress = */ 2 | USB_DIR_OUT, /* .bmAttributes = */ 0x02, @@ -118,19 +119,26 @@ __code usb_endpoint_descriptor_t Bulk_EP2_OUT_Endpoint_Descriptor = { /* .bInterval = */ 0 }; -__code usb_language_descriptor_t language_descriptor = { +__code struct usb_language_descriptor language_descriptor = { /* .bLength = */ 4, /* .bDescriptorType = */ DESCRIPTOR_TYPE_STRING, /* .wLANGID = */ {0x0409 /* US English */} }; -__code usb_string_descriptor_t strManufacturer = STR_DESCR(9,'O','p','e','n','U','L','I','N','K'); -__code usb_string_descriptor_t strProduct = STR_DESCR(9,'O','p','e','n','U','L','I','N','K'); -__code usb_string_descriptor_t strSerialNumber = STR_DESCR(6, '0','0','0','0','0','1'); -__code usb_string_descriptor_t strConfigDescr = STR_DESCR(12, 'J','T','A','G',' ','A','d','a','p','t','e','r'); +__code struct usb_string_descriptor strManufacturer = + STR_DESCR(9,'O','p','e','n','U','L','I','N','K'); + +__code struct usb_string_descriptor strProduct = + STR_DESCR(9,'O','p','e','n','U','L','I','N','K'); + +__code struct usb_string_descriptor strSerialNumber = + STR_DESCR(6, '0','0','0','0','0','1'); + +__code struct usb_string_descriptor strConfigDescr = + STR_DESCR(12, 'J','T','A','G',' ','A','d','a','p','t','e','r'); /* Table containing pointers to string descriptors */ -__code usb_string_descriptor_t* __code en_string_descriptors[4] = { +__code struct usb_string_descriptor* __code en_string_descriptors[4] = { &strManufacturer, &strProduct, &strSerialNumber, -- 2.39.5