update files to correct FSF address
[openocd.git] / src / jtag / drivers / OpenULINK / include / usb.h
index f70819eab413788d45631a11263998e9b2336ff8..6e6b928fa8f29e3a1cc69cc022c60867045b456c 100644 (file)
  *   You should have received a copy of the GNU General Public License     *
  *   along with this program; if not, write to the                         *
  *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.           *
  ***************************************************************************/
 
 #ifndef __USB_H
 #define __USB_H
 
-#include "shorttypes.h"
 #include "reg_ezusb.h"
 
+#include <stdint.h>
 #include <stdbool.h>
 
-#define NULL        (void*)0;
+#define NULL        (void *)0;
 
-/* High and Low byte of a word (u16) */
-#define HI8(word)   (u8)(((u16)word >> 8) & 0xff)
-#define LO8(word)   (u8)((u16)word & 0xff)
+/* High and Low byte of a word (uint16_t) */
+#define HI8(word)   (uint8_t)(((uint16_t)word >> 8) & 0xff)
+#define LO8(word)   (uint8_t)((uint16_t)word & 0xff)
 
 /* Convenience functions */
-#define STALL_EP0()   EP0CS |= EP0STALL
-#define CLEAR_IRQ()   EXIF &= ~USBINT
+#define STALL_EP0()   (EP0CS |= EP0STALL)
+#define CLEAR_IRQ()   (EXIF &= ~USBINT)
 
 /*********** USB descriptors. See section 9.5 of the USB 1.1 spec **********/
 
 #define DESCRIPTOR_TYPE_INTERFACE      0x04
 #define DESCRIPTOR_TYPE_ENDPOINT       0x05
 
-#define STR_DESCR(len,...) { len*2+2, DESCRIPTOR_TYPE_STRING, { __VA_ARGS__ } }
+#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 {
-  u8  bLength;             ///< Size of this descriptor in bytes.
-  u8  bDescriptorType;     ///< DEVICE Descriptor Type.
-  u16 bcdUSB;              ///< USB specification release number (BCD).
-  u8  bDeviceClass;        ///< Class code.
-  u8  bDeviceSubClass;     ///< Subclass code.
-  u8  bDeviceProtocol;     ///< Protocol code.
-  u8  bMaxPacketSize0;     ///< Maximum packet size for EP0 (8, 16, 32, 64).
-  u16 idVendor;            ///< USB Vendor ID.
-  u16 idProduct;           ///< USB Product ID.
-  u16 bcdDevice;           ///< Device Release Number (BCD).
-  u8  iManufacturer;       ///< Index of manufacturer string descriptor.
-  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;
+struct usb_device_descriptor {
+       uint8_t bLength;        /* /< Size of this descriptor in bytes. */
+       uint8_t bDescriptorType;/* /< DEVICE Descriptor Type. */
+       uint16_t bcdUSB;        /* /< USB specification release number (BCD). */
+       uint8_t bDeviceClass;   /* /< Class code. */
+       uint8_t bDeviceSubClass;/* /< Subclass code. */
+       uint8_t bDeviceProtocol;/* /< Protocol code. */
+       uint8_t bMaxPacketSize0;/* /< Maximum packet size for EP0 (8, 16, 32, 64). */
+       uint16_t idVendor;      /* /< USB Vendor ID. */
+       uint16_t idProduct;     /* /< USB Product ID. */
+       uint16_t bcdDevice;     /* /< Device Release Number (BCD). */
+       uint8_t iManufacturer;  /* /< Index of manufacturer string descriptor. */
+       uint8_t iProduct;       /* /< Index of product string descriptor. */
+       uint8_t iSerialNumber;  /* /< Index of string descriptor containing serial #. */
+       uint8_t bNumConfigurations;     /* /< Number of possible configurations. */
+};
 
 /** USB Configuration Descriptor. See USB 1.1 spec, pp. 199 - 200 */
-typedef struct {
-  u8  bLength;             ///< Size of this descriptor in bytes.
-  u8  bDescriptorType;     ///< CONFIGURATION descriptor type.
-  u16 wTotalLength;        ///< Combined total length of all descriptors.
-  u8  bNumInterfaces;      ///< Number of interfaces in this configuration.
-  u8  bConfigurationValue; ///< Value used to select this configuration.
-  u8  iConfiguration;      ///< Index of configuration string descriptor.
-  u8  bmAttributes;        ///< Configuration characteristics.
-  u8  MaxPower;            ///< Maximum power consumption in 2 mA units.
-} usb_config_descriptor_t;
+struct usb_config_descriptor {
+       uint8_t bLength;        /* /< Size of this descriptor in bytes. */
+       uint8_t bDescriptorType;/* /< CONFIGURATION descriptor type. */
+       uint16_t wTotalLength;  /* /< Combined total length of all descriptors. */
+       uint8_t bNumInterfaces; /* /< Number of interfaces in this configuration. */
+       uint8_t bConfigurationValue;    /* /< Value used to select this configuration. */
+       uint8_t iConfiguration; /* /< Index of configuration string descriptor. */
+       uint8_t bmAttributes;   /* /< Configuration characteristics. */
+       uint8_t MaxPower;       /* /< Maximum power consumption in 2 mA units. */
+};
 
 /** USB Interface Descriptor. See USB 1.1 spec, pp. 201 - 203 */
-typedef struct {
-  u8  bLength;             ///< Size of this descriptor in bytes.
-  u8  bDescriptorType;     ///< INTERFACE descriptor type.
-  u8  bInterfaceNumber;    ///< Interface number.
-  u8  bAlternateSetting;   ///< Value used to select alternate setting.
-  u8  bNumEndpoints;       ///< Number of endpoints used by this interface.
-  u8  bInterfaceClass;     ///< Class code.
-  u8  bInterfaceSubclass;  ///< Subclass code.
-  u8  bInterfaceProtocol;  ///< Protocol code.
-  u8  iInterface;          ///< Index of interface string descriptor.
-} usb_interface_descriptor_t;
+struct usb_interface_descriptor {
+       uint8_t bLength;        /* /< Size of this descriptor in bytes. */
+       uint8_t bDescriptorType;/* /< INTERFACE descriptor type. */
+       uint8_t bInterfaceNumber;       /* /< Interface number. */
+       uint8_t bAlternateSetting;      /* /< Value used to select alternate setting. */
+       uint8_t bNumEndpoints;  /* /< Number of endpoints used by this interface. */
+       uint8_t bInterfaceClass;/* /< Class code. */
+       uint8_t bInterfaceSubclass;     /* /< Subclass code. */
+       uint8_t bInterfaceProtocol;     /* /< Protocol code. */
+       uint8_t iInterface;     /* /< Index of interface string descriptor. */
+};
 
 /** USB Endpoint Descriptor. See USB 1.1 spec, pp. 203 - 204 */
-typedef struct {
-  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;
+struct usb_endpoint_descriptor {
+       uint8_t bLength;        /* /< Size of this descriptor in bytes. */
+       uint8_t bDescriptorType;/* /< ENDPOINT descriptor type. */
+       uint8_t bEndpointAddress;       /* /< Endpoint Address: USB 1.1 spec, table 9-10. */
+       uint8_t bmAttributes;   /* /< Endpoint Attributes: USB 1.1 spec, table 9-10. */
+       uint16_t wMaxPacketSize;/* /< Maximum packet size for this endpoint. */
+       uint8_t bInterval;      /* /< Polling interval (in ms) for this endpoint. */
+};
 
 /** USB Language Descriptor. See USB 1.1 spec, pp. 204 - 205 */
-typedef struct {
-  u8  bLength;             ///< Size of this descriptor in bytes.
-  u8  bDescriptorType;     ///< STRING descriptor type.
-  u16 wLANGID[];           ///< LANGID codes.
-} usb_language_descriptor_t;
+struct usb_language_descriptor {
+       uint8_t bLength;        /* /< Size of this descriptor in bytes. */
+       uint8_t bDescriptorType;/* /< STRING descriptor type. */
+       uint16_t wLANGID[];     /* /< LANGID codes. */
+};
 
 /** USB String Descriptor. See USB 1.1 spec, pp. 204 - 205 */
-typedef struct {
-  u8  bLength;             ///< Size of this descriptor in bytes.
-  u8  bDescriptorType;     ///< STRING descriptor type.
-  u16 bString[];           ///< UNICODE encoded string.
-} usb_string_descriptor_t;
+struct usb_string_descriptor {
+       uint8_t bLength;        /* /< Size of this descriptor in bytes. */
+       uint8_t bDescriptorType;/* /< STRING descriptor type. */
+       uint16_t bString[];     /* /< UNICODE encoded string. */
+};
 
 /********************** USB Control Endpoint 0 related *********************/
 
 /** USB Control Setup Data. See USB 1.1 spec, pp. 183 - 185 */
-typedef struct {
-  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;
+struct setup_data {
+       uint8_t bmRequestType;  /* /< Characteristics of a request. */
+       uint8_t bRequest;       /* /< Specific request. */
+       uint16_t wValue;        /* /< Field that varies according to request. */
+       uint16_t wIndex;        /* /< Field that varies according to request. */
+       uint16_t wLength;       /* /< Number of bytes to transfer in data stage. */
+};
 
 /* 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
@@ -206,9 +206,9 @@ extern volatile __xdata __at 0x7FE8 setup_data_t setup_data;
 /* USB Requests (bRequest): See USB 1.1 spec, table 9-4 on page 187 */
 #define GET_STATUS               0
 #define CLEAR_FEATURE            1
-// Value '2' is reserved for future use
+/* Value '2' is reserved for future use */
 #define SET_FEATURE              3
-// Value '4' is reserved for future use
+/* Value '4' is reserved for future use */
 #define SET_ADDRESS              5
 #define GET_DESCRIPTOR           6
 #define SET_DESCRIPTOR           7
@@ -225,35 +225,35 @@ 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 {
-  SUDAV_ISR = 13,
-  SOF_ISR,
-  SUTOK_ISR,
-  SUSPEND_ISR,
-  USBRESET_ISR,
-  IBN_ISR,
-  EP0IN_ISR,
-  EP0OUT_ISR,
-  EP1IN_ISR,
-  EP1OUT_ISR,
-  EP2IN_ISR,
-  EP2OUT_ISR,
-  EP3IN_ISR,
-  EP3OUT_ISR,
-  EP4IN_ISR,
-  EP4OUT_ISR,
-  EP5IN_ISR,
-  EP5OUT_ISR,
-  EP6IN_ISR,
-  EP6OUT_ISR,
-  EP7IN_ISR,
-  EP7OUT_ISR
-} USB_ISR;
+enum usb_isr {
+       SUDAV_ISR = 13,
+       SOF_ISR,
+       SUTOK_ISR,
+       SUSPEND_ISR,
+       USBRESET_ISR,
+       IBN_ISR,
+       EP0IN_ISR,
+       EP0OUT_ISR,
+       EP1IN_ISR,
+       EP1OUT_ISR,
+       EP2IN_ISR,
+       EP2OUT_ISR,
+       EP3IN_ISR,
+       EP3OUT_ISR,
+       EP4IN_ISR,
+       EP4OUT_ISR,
+       EP5IN_ISR,
+       EP5OUT_ISR,
+       EP6IN_ISR,
+       EP6OUT_ISR,
+       EP7IN_ISR,
+       EP7OUT_ISR
+};
 
 /*************************** Function Prototypes ***************************/
 
-__xdata u8* usb_get_endpoint_cs_reg(u8 ep);
-void usb_reset_data_toggle(u8 ep);
+__xdata uint8_t *usb_get_endpoint_cs_reg(uint8_t ep);
+void usb_reset_data_toggle(uint8_t ep);
 
 bool usb_handle_get_status(void);
 bool usb_handle_clear_feature(void);

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)