contrib/firmware: add new i2c bit-banging feature to angie's firmware
[openocd.git] / contrib / firmware / angie / c / include / usb.h
index 0450d1d1c949c82ae986542169560c2cfd26fd34..07cb12ae6a621714df44db51df2d9327685154cf 100644 (file)
 #define STALL_EP0()   (EP0CS |= EPSTALL)
 #define CLEAR_IRQ()   (USBINT = 0)
 
-/*********** USB descriptors. See section 9.5 of the USB 1.1 spec **********/
+/*********** USB descriptors. See USB 2.0 Spec **********/
 
-/* USB Descriptor Types. See USB 1.1 spec, page 187, table 9-5 */
-#define DESCRIPTOR_TYPE_DEVICE         0x01
-#define DESCRIPTOR_TYPE_CONFIGURATION  0x02
-#define DESCRIPTOR_TYPE_STRING         0x03
-#define DESCRIPTOR_TYPE_INTERFACE      0x04
-#define DESCRIPTOR_TYPE_ENDPOINT       0x05
+/* USB Descriptor Types. See USB 2.0 Spec */
+#define DESCRIPTOR_TYPE_DEVICE                      0x01
+#define DESCRIPTOR_TYPE_CONFIGURATION               0x02
+#define DESCRIPTOR_TYPE_STRING                      0x03
+#define DESCRIPTOR_TYPE_INTERFACE                   0x04
+#define DESCRIPTOR_TYPE_ENDPOINT                    0x05
+#define DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION       0x0B
 
 #define STR_DESCR(len, ...) { (len) * 2 + 2, DESCRIPTOR_TYPE_STRING, { __VA_ARGS__ } }
 
-/** USB Device Descriptor. See USB 1.1 spec, pp. 196 - 198 */
+/** USB Device Descriptor. See USB 2.0 Spec */
 struct usb_device_descriptor {
        uint8_t blength;                /**< Size of this descriptor in bytes. */
        uint8_t bdescriptortype;        /**< DEVICE Descriptor Type. */
@@ -53,7 +54,7 @@ struct usb_device_descriptor {
        uint8_t bnumconfigurations;     /**< Number of possible configurations. */
 };
 
-/** USB Configuration Descriptor. See USB 1.1 spec, pp. 199 - 200 */
+/** USB Configuration Descriptor. See USB 2.0 Spec */
 struct usb_config_descriptor {
        uint8_t blength;                /**< Size of this descriptor in bytes. */
        uint8_t bdescriptortype;        /**< CONFIGURATION descriptor type. */
@@ -65,7 +66,19 @@ struct usb_config_descriptor {
        uint8_t maxpower;               /**< Maximum power consumption in 2 mA units. */
 };
 
-/** USB Interface Descriptor. See USB 1.1 spec, pp. 201 - 203 */
+/** USB Interface association Descriptor. See USB 2.0 Spec */
+struct usb_interface_association_descriptor {
+       uint8_t  blength;
+       uint8_t  bdescriptortype;
+       uint8_t  bfirstinterface;
+       uint8_t  binterfacecount;
+       uint8_t  bfunctionclass;
+       uint8_t  bfunctionsubclass;
+       uint8_t  bfunctionprotocol;
+       uint8_t  ifunction;
+};
+
+/** USB Interface Descriptor. See USB 2.0 Spec */
 struct usb_interface_descriptor {
        uint8_t blength;                /**< Size of this descriptor in bytes. */
        uint8_t bdescriptortype;        /**< INTERFACE descriptor type. */
@@ -78,7 +91,7 @@ struct usb_interface_descriptor {
        uint8_t iinterface;             /**< Index of interface string descriptor. */
 };
 
-/** USB Endpoint Descriptor. See USB 1.1 spec, pp. 203 - 204 */
+/** USB Endpoint Descriptor. See USB 2.0 Spec */
 struct usb_endpoint_descriptor {
        uint8_t blength;                /**< Size of this descriptor in bytes. */
        uint8_t bdescriptortype;        /**< ENDPOINT descriptor type. */
@@ -88,14 +101,14 @@ struct usb_endpoint_descriptor {
        uint8_t binterval;              /**< Polling interval (in ms) for this endpoint. */
 };
 
-/** USB Language Descriptor. See USB 1.1 spec, pp. 204 - 205 */
+/** USB Language Descriptor. See USB 2.0 Spec */
 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 */
+/** USB String Descriptor. See USB 2.0 Spec */
 struct usb_string_descriptor {
        uint8_t blength;                /**< Size of this descriptor in bytes. */
        uint8_t bdescriptortype;        /**< STRING descriptor type. */
@@ -104,7 +117,7 @@ struct usb_string_descriptor {
 
 /********************** USB Control Endpoint 0 related *********************/
 
-/** USB Control Setup Data. See USB 1.1 spec, pp. 183 - 185 */
+/** USB Control Setup Data. See USB 2.0 Spec */
 struct setup_data {
        uint8_t bmrequesttype;          /**< Characteristics of a request. */
        uint8_t brequest;               /**< Specific request. */
@@ -121,66 +134,66 @@ extern volatile bool ep1_in;
 extern volatile __xdata __at 0xE6B8 struct setup_data setup_data;
 
 /*
- * USB Request Types (bmRequestType): See USB 1.1 spec, page 183, table 9-2
+ * USB Request Types (bmRequestType): See USB 2.0 Spec
  *
  * Bit 7: Data transfer direction
- *    0 = Host-to-device
- *    1 = Device-to-host
+ *     0 = Host-to-device
+ *     1 = Device-to-host
  * Bit 6...5: Type
- *    0 = Standard
- *    1 = Class
- *    2 = Vendor
- *    3 = Reserved
+ *     0 = Standard
+ *     1 = Class
+ *     2 = Vendor
+ *     3 = Reserved
  * Bit 4...0: Recipient
- *    0 = Device
- *    1 = Interface
- *    2 = Endpoint
- *    3 = Other
- *    4...31 = Reserved
+ *     0 = Device
+ *     1 = Interface
+ *     2 = Endpoint
+ *     3 = Other
+ *     4...31 = Reserved
  */
 
-#define USB_DIR_OUT             0x00
-#define USB_DIR_IN              0x80
+#define USB_DIR_OUT         0x00
+#define USB_DIR_IN          0x80
 
 #define USB_REQ_TYPE_STANDARD   (0x00 << 5)
 #define USB_REQ_TYPE_CLASS      (0x01 << 5)
 #define USB_REQ_TYPE_VENDOR     (0x02 << 5)
 #define USB_REQ_TYPE_RESERVED   (0x03 << 5)
 
-#define USB_RECIP_DEVICE        0x00
-#define USB_RECIP_INTERFACE     0x01
-#define USB_RECIP_ENDPOINT      0x02
-#define USB_RECIP_OTHER         0x03
+#define USB_RECIP_DEVICE    0x00
+#define USB_RECIP_INTERFACE 0x01
+#define USB_RECIP_ENDPOINT  0x02
+#define USB_RECIP_OTHER     0x03
 
 /* Clear Interface Request */
-#define CF_DEVICE    (USB_DIR_OUT | USB_REQ_TYPE_STANDARD | USB_RECIP_DEVICE)
+#define CF_DEVICE      (USB_DIR_OUT | USB_REQ_TYPE_STANDARD | USB_RECIP_DEVICE)
 #define CF_INTERFACE (USB_DIR_OUT | USB_REQ_TYPE_STANDARD | USB_RECIP_INTERFACE)
 #define CF_ENDPOINT  (USB_DIR_OUT | USB_REQ_TYPE_STANDARD | USB_RECIP_ENDPOINT)
 
 /* Get Configuration Request */
-#define GC_DEVICE    (USB_DIR_IN | USB_REQ_TYPE_STANDARD | USB_RECIP_DEVICE)
+#define GC_DEVICE      (USB_DIR_IN | USB_REQ_TYPE_STANDARD | USB_RECIP_DEVICE)
 
 /* Get Descriptor Request */
-#define GD_DEVICE    (USB_DIR_IN | USB_REQ_TYPE_STANDARD | USB_RECIP_DEVICE)
+#define GD_DEVICE      (USB_DIR_IN | USB_REQ_TYPE_STANDARD | USB_RECIP_DEVICE)
 
 /* Get Interface Request */
 #define GI_INTERFACE (USB_DIR_IN | USB_REQ_TYPE_STANDARD | USB_RECIP_INTERFACE)
 
 /* Get Status Request: See USB 1.1 spec, page 190 */
-#define GS_DEVICE    (USB_DIR_IN | USB_REQ_TYPE_STANDARD | USB_RECIP_DEVICE)
+#define GS_DEVICE      (USB_DIR_IN | USB_REQ_TYPE_STANDARD | USB_RECIP_DEVICE)
 #define GS_INTERFACE (USB_DIR_IN | USB_REQ_TYPE_STANDARD | USB_RECIP_INTERFACE)
 #define GS_ENDPOINT  (USB_DIR_IN | USB_REQ_TYPE_STANDARD | USB_RECIP_ENDPOINT)
 
 /* Set Address Request is handled by EZ-USB core */
 
 /* Set Configuration Request */
-#define SC_DEVICE    (USB_DIR_OUT | USB_REQ_TYPE_STANDARD | USB_RECIP_DEVICE)
+#define SC_DEVICE      (USB_DIR_OUT | USB_REQ_TYPE_STANDARD | USB_RECIP_DEVICE)
 
 /* Set Descriptor Request */
-#define SD_DEVICE    (USB_DIR_OUT | USB_REQ_TYPE_STANDARD | USB_RECIP_DEVICE)
+#define SD_DEVICE      (USB_DIR_OUT | USB_REQ_TYPE_STANDARD | USB_RECIP_DEVICE)
 
 /* Set Feature Request */
-#define SF_DEVICE    (USB_DIR_OUT | USB_REQ_TYPE_STANDARD | USB_RECIP_DEVICE)
+#define SF_DEVICE      (USB_DIR_OUT | USB_REQ_TYPE_STANDARD | USB_RECIP_DEVICE)
 #define SF_INTERFACE (USB_DIR_OUT | USB_REQ_TYPE_STANDARD | USB_RECIP_INTERFACE)
 #define SF_ENDPOINT  (USB_DIR_OUT | USB_REQ_TYPE_STANDARD | USB_RECIP_ENDPOINT)
 
@@ -190,27 +203,27 @@ extern volatile __xdata __at 0xE6B8 struct setup_data setup_data;
 /* Synch Frame Request */
 #define SY_ENDPOINT  (USB_DIR_IN | USB_REQ_TYPE_STANDARD | USB_RECIP_ENDPOINT)
 
-/* USB Requests (bRequest): See USB 1.1 spec, table 9-4 on page 187 */
-#define GET_STATUS               0
-#define CLEAR_FEATURE            1
+/* USB Requests (bRequest): See USB 2.0 Spec */
+#define GET_STATUS              0
+#define CLEAR_FEATURE           1
 /* Value '2' is reserved for future use */
-#define SET_FEATURE              3
+#define SET_FEATURE             3
 /* Value '4' is reserved for future use */
-#define SET_ADDRESS              5
-#define GET_DESCRIPTOR           6
-#define SET_DESCRIPTOR           7
-#define GET_CONFIGURATION        8
-#define SET_CONFIGURATION        9
+#define SET_ADDRESS             5
+#define GET_DESCRIPTOR          6
+#define SET_DESCRIPTOR          7
+#define GET_CONFIGURATION       8
+#define SET_CONFIGURATION              9
 #define GET_INTERFACE           10
 #define SET_INTERFACE           11
 #define SYNCH_FRAME             12
 
-/* Standard Feature Selectors: See USB 1.1 spec, table 9-6 on page 188 */
-#define DEVICE_REMOTE_WAKEUP     1
-#define ENDPOINT_HALT            0
+/* Standard Feature Selectors: See USB 2.0 Spec */
+#define DEVICE_REMOTE_WAKEUP    1
+#define ENDPOINT_HALT           0
 
 /************************** EZ-USB specific stuff **************************/
-/** USB Interrupts. See AN2131-TRM, page 9-4 for details */
+/** USB Interrupts. See EZ-USB FX2-TRM, for details */
 enum usb_isr {
        SUDAV_ISR = 13,
        SOF_ISR,
@@ -265,7 +278,10 @@ bool usb_handle_set_feature(void);
 bool usb_handle_get_descriptor(void);
 void usb_handle_set_interface(void);
 void usb_handle_setup_data(void);
+void usb_handle_i2c_in(void);
+void usb_handle_i2c_out(void);
 
+void i2c_recieve(void);
 void ep_init(void);
 void interrupt_init(void);
 void io_init(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)