IceCube display
LED display to show IceCube event data
descriptor.h
Go to the documentation of this file.
1 #ifndef USB_DESCRIPTOR_H
2 #define USB_DESCRIPTOR_H
3 
29 #include <stdint.h>
30 #include <stdbool.h>
31 
32 #include "usb/std.h"
33 #include "memspace.h"
34 
44 };
45 
48  uint8_t bLength;
49  uint8_t bDescriptorType;
50 } __attribute__((packed));
51 
57 uint8_t usb_descriptor_size(
58  const enum usb_descriptor_type_t type
59  , const void* body
60  , const enum memspace_t memspace
61 );
62 
73  const enum usb_descriptor_type_t type
74  , const void* body
75  , const enum memspace_t memspace
76 );
77 
86  struct usb_descriptor_header_t header;
87  enum memspace_t memspace;
88  const void* body;
90 };
91 
99 
106 uint16_t get_list_total_length(const struct descriptor_list_t* head);
107 
110  uint16_t bcdUSB;
111  uint8_t bDeviceClass;
112  uint8_t bDeviceSubClass;
113  uint8_t bDeviceProtocol;
114  uint8_t bMaxPacketSize;
115  uint16_t idVendor;
116  uint16_t idProduct;
117  uint16_t bcdDevice;
118  uint8_t iManufacturer;
119  uint8_t iProduct;
120  uint8_t iSerialNumber;
121  uint8_t bNumConfigurations;
122 } __attribute__((packed));
123 
126  uint16_t wTotalLength;
127  uint8_t bNumInterfaces;
128  uint8_t bConfigurationValue;
129  uint8_t iConfiguration;
130  uint8_t bmAttributes;
131  uint8_t bMaxPower;
132 } __attribute__((packed));
133 
134 #define USB_CONFIG_ATTRIBUTES(self_powered, remote_wakeup) \
135  ((1<<7)|((self_powered)<<6)|((remote_wakeup)<<5))
136 #define USB_MAX_POWER(milli_amps) (milli_amps/2)
137 
140  uint8_t bInterfaceNumber;
141  uint8_t bAlternateSetting;
142  uint8_t bNumEndPoints;
143  uint8_t bInterfaceClass;
144  uint8_t bInterfaceSubClass;
145  uint8_t bInterfaceProtocol;
146  uint8_t iInterface;
147 } __attribute__((packed));
148 
151  uint8_t bEndpointAddress;
152  uint8_t bmAttributes;
153  uint16_t wMaxPacketSize;
154  uint8_t bInterval;
155 } __attribute__((packed));
156 
157 #endif
Interface descriptor.
Definition: descriptor.h:42
Configuration descriptor body.
Definition: descriptor.h:125
const void * body
Pointer to the descriptor body.
Definition: descriptor.h:88
uint8_t bLength
Total byte size of the descriptor.
Definition: descriptor.h:48
struct descriptor_list_t * next
Pointer to the next item or NULL if this is the last one.
Definition: descriptor.h:89
uint8_t bDescriptorType
Type of the descriptor; see usb_descriptor_type_t.
Definition: descriptor.h:49
Endpoint descriptor.
Definition: descriptor.h:43
Single item of a linked list of descriptors.
Definition: descriptor.h:85
Endpoint descriptor body.
Definition: descriptor.h:150
usb_descriptor_type_t
Definition: descriptor.h:38
uint8_t usb_descriptor_size(const enum usb_descriptor_type_t type, const void *body, const enum memspace_t memspace)
Calculate the total size of a USB descriptor.
Interface descriptor body.
Definition: descriptor.h:139
Definitions of constants as described by the USB 2.0 standard.
uint16_t get_list_total_length(const struct descriptor_list_t *head)
Calculate the sum of all descriptor sizes in a linked list.
Device descriptor body.
Definition: descriptor.h:109
Definition: std.h:102
uint8_t usb_descriptor_body_size(const enum usb_descriptor_type_t type, const void *body, const enum memspace_t memspace)
Calculate the size of a USB descriptor&#39;s body.
String descriptor.
Definition: descriptor.h:41
Non-uniform memory access.
memspace_t
Define which memory space the body of a data block is in.
Definition: memspace.h:15
Device descriptor.
Definition: descriptor.h:39
Configuration descriptor.
Definition: descriptor.h:40
struct descriptor_list_t * generate_descriptor_list(const struct usb_setup_packet_t *req)
Common header used for all USB descriptors.
Definition: descriptor.h:47