1 /* 2 * Copyright (c) 2015 Brian Swetland 3 * Copyright (c) 2008 Google, Inc. 4 * 5 * Use of this source code is governed by a MIT-style 6 * license that can be found in the LICENSE file or at 7 * https://opensource.org/licenses/MIT 8 */ 9 #pragma once 10 11 #define GET_STATUS 0 12 #define CLEAR_FEATURE 1 13 #define SET_FEATURE 3 14 #define SET_ADDRESS 5 15 #define GET_DESCRIPTOR 6 16 #define SET_DESCRIPTOR 7 17 #define GET_CONFIGURATION 8 18 #define SET_CONFIGURATION 9 19 #define GET_INTERFACE 10 20 #define SET_INTERFACE 11 21 #define SYNCH_FRAME 12 22 #define SET_SEL 48 23 24 #define TYPE_DEVICE 1 25 #define TYPE_CONFIGURATION 2 26 #define TYPE_STRING 3 27 #define TYPE_INTERFACE 4 28 #define TYPE_ENDPOINT 5 29 #define TYPE_BOS 15 30 #define TYPE_DEVICE_CAP 16 31 #define TYPE_SS_EP_COMP 48 32 33 #define DEVICE_READ 0x80 34 #define DEVICE_WRITE 0x00 35 #define INTERFACE_READ 0x81 36 #define INTERFACE_WRITE 0x01 37 #define ENDPOINT_READ 0x82 38 #define ENDPOINT_WRITE 0x02 39 40 typedef struct udc_descriptor udc_descriptor_t; 41 42 union setup_packet { 43 struct { 44 uint8_t type; 45 uint8_t request; 46 uint16_t value; 47 uint16_t index; 48 uint16_t length; 49 }; 50 struct { 51 uint32_t w0; 52 uint32_t w1; 53 }; 54 } __attribute__ ((packed)); 55 56 struct udc_descriptor { 57 udc_descriptor_t *next; 58 uint16_t tag; /* ((TYPE << 8) | NUM) */ 59 uint16_t len; /* total length */ 60 uint8_t data[4]; 61 }; 62 63 // driver calls this to build descriptors from device and gadgets 64 void udc_create_descriptors(udc_device_t *device, udc_gadget_t *gadget); 65 66 // driver uses this to obtain descriptors 67 udc_descriptor_t *udc_descriptor_find(unsigned tag); 68 69 // driver provides this 70 void udc_ept_desc_fill(udc_endpoint_t *ept, unsigned char *data); 71 72