Mercurial > ~darius > hgwebdir.cgi > tempctrl
comparison usb.h @ 31:4e417d84365e
- Rename some more functions to be consistent.
- Add some delays when talking to the 'D12 - probably not needed.
- Add some comments at the top of each function.
- Log endpoint errors.
- Whitespace changes.
- Remove exact_Bytes crap.
- Many other changes I have made in an attempt to get it to work
consistently (but no luck yet).
author | darius |
---|---|
date | Mon, 10 Apr 2006 17:27:48 +0930 |
parents | 845934a4e7fe |
children | fed32b382de2 |
comparison
equal
deleted
inserted
replaced
30:48056516b3eb | 31:4e417d84365e |
---|---|
12 uint8_t bmRequestType; | 12 uint8_t bmRequestType; |
13 uint8_t bRequest; | 13 uint8_t bRequest; |
14 uint16_t wValue; | 14 uint16_t wValue; |
15 uint16_t wIndex; | 15 uint16_t wIndex; |
16 uint16_t wLength; | 16 uint16_t wLength; |
17 } USB_SETUP_REQUEST; | 17 } __attribute__ ((packed)) USB_SETUP_REQUEST; |
18 | 18 |
19 typedef struct { | 19 typedef struct { |
20 uint8_t bLength; | 20 uint8_t bLength; |
21 uint8_t bDescriptorType; | 21 uint8_t bDescriptorType; |
22 uint16_t bcdUSB; | 22 uint16_t bcdUSB; |
29 uint16_t bcdDevice; | 29 uint16_t bcdDevice; |
30 uint8_t iManufacturer; | 30 uint8_t iManufacturer; |
31 uint8_t iProduct; | 31 uint8_t iProduct; |
32 uint8_t iSerialNumber; | 32 uint8_t iSerialNumber; |
33 uint8_t bNumConfigurations; | 33 uint8_t bNumConfigurations; |
34 } USB_DEVICE_DESCRIPTOR; | 34 } __attribute__ ((packed)) USB_DEVICE_DESCRIPTOR; |
35 | 35 |
36 typedef struct { | 36 typedef struct { |
37 uint8_t bLength; | 37 uint8_t bLength; |
38 uint8_t bDescriptorType; | 38 uint8_t bDescriptorType; |
39 uint8_t bEndpointAddress; | 39 uint8_t bEndpointAddress; |
40 uint8_t bmAttributes; | 40 uint8_t bmAttributes; |
41 uint16_t wMaxPacketSize; | 41 uint16_t wMaxPacketSize; |
42 uint8_t bInterval; | 42 uint8_t bInterval; |
43 } USB_ENDPOINT_DESCRIPTOR; | 43 } __attribute__ ((packed)) USB_ENDPOINT_DESCRIPTOR; |
44 | 44 |
45 typedef struct { | 45 typedef struct { |
46 uint8_t bLength; | 46 uint8_t bLength; |
47 uint8_t bDescriptorType; | 47 uint8_t bDescriptorType; |
48 uint16_t wTotalLength; | 48 uint16_t wTotalLength; |
49 uint8_t bNumInterfaces; | 49 uint8_t bNumInterfaces; |
50 uint8_t bConfigurationValue; | 50 uint8_t bConfigurationValue; |
51 uint8_t iConfiguration; | 51 uint8_t iConfiguration; |
52 uint8_t bmAttributes; | 52 uint8_t bmAttributes; |
53 uint8_t MaxPower; | 53 uint8_t MaxPower; |
54 } USB_CONFIGURATION_DESCRIPTOR; | 54 } __attribute__ ((packed)) USB_CONFIGURATION_DESCRIPTOR; |
55 | 55 |
56 typedef struct { | 56 typedef struct { |
57 uint8_t bLength; | 57 uint8_t bLength; |
58 uint8_t bDescriptorType; | 58 uint8_t bDescriptorType; |
59 uint8_t bInterfaceNumber; | 59 uint8_t bInterfaceNumber; |
61 uint8_t bNumEndpoints; | 61 uint8_t bNumEndpoints; |
62 uint8_t bInterfaceClass; | 62 uint8_t bInterfaceClass; |
63 uint8_t bInterfaceSubClass; | 63 uint8_t bInterfaceSubClass; |
64 uint8_t bInterfaceProtocol; | 64 uint8_t bInterfaceProtocol; |
65 uint8_t iInterface; | 65 uint8_t iInterface; |
66 } USB_INTERFACE_DESCRIPTOR; | 66 } __attribute__ ((packed)) USB_INTERFACE_DESCRIPTOR; |
67 | 67 |
68 typedef struct { | 68 typedef struct { |
69 uint8_t bLength; | 69 uint8_t bLength; |
70 uint8_t bDescriptorType; | 70 uint8_t bDescriptorType; |
71 uint16_t wHIDClassSpecComp; | 71 uint16_t wHIDClassSpecComp; |
72 uint8_t bCountry; | 72 uint8_t bCountry; |
73 uint8_t bNumDescriptors; | 73 uint8_t bNumDescriptors; |
74 uint8_t b1stDescType; | 74 uint8_t b1stDescType; |
75 uint16_t w1stDescLength; | 75 uint16_t w1stDescLength; |
76 } USB_HID_DESCRIPTOR; | 76 } __attribute__ ((packed)) USB_HID_DESCRIPTOR; |
77 | 77 |
78 typedef struct { | 78 typedef struct { |
79 USB_CONFIGURATION_DESCRIPTOR ConfigDescriptor; | 79 USB_CONFIGURATION_DESCRIPTOR ConfigDescriptor; |
80 USB_INTERFACE_DESCRIPTOR InterfaceDescriptor0; | 80 USB_INTERFACE_DESCRIPTOR InterfaceDescriptor0; |
81 USB_ENDPOINT_DESCRIPTOR EndpointDescriptor00; | 81 USB_ENDPOINT_DESCRIPTOR EndpointDescriptor00; |
82 USB_ENDPOINT_DESCRIPTOR EndpointDescriptor01; | 82 USB_ENDPOINT_DESCRIPTOR EndpointDescriptor01; |
83 USB_INTERFACE_DESCRIPTOR InterfaceDescriptor1; | 83 USB_INTERFACE_DESCRIPTOR InterfaceDescriptor1; |
84 USB_ENDPOINT_DESCRIPTOR EndpointDescriptor10; | 84 USB_ENDPOINT_DESCRIPTOR EndpointDescriptor10; |
85 USB_ENDPOINT_DESCRIPTOR EndpointDescriptor11; | 85 USB_ENDPOINT_DESCRIPTOR EndpointDescriptor11; |
86 } USB_CONFIG_DATA; | 86 } __attribute__ ((packed)) USB_CONFIG_DATA; |
87 | 87 |
88 typedef struct { | 88 typedef struct { |
89 uint8_t bLength; | 89 uint8_t bLength; |
90 uint8_t bDescriptorType; | 90 uint8_t bDescriptorType; |
91 char bString[]; | 91 char bString[]; |
92 } STRING_DESCRIPTOR; | 92 } __attribute__ ((packed)) STRING_DESCRIPTOR; |
93 | 93 |
94 typedef struct { | 94 typedef struct { |
95 uint8_t bLength; | 95 uint8_t bLength; |
96 uint8_t bDescriptorType; | 96 uint8_t bDescriptorType; |
97 uint16_t wLANGID0; | 97 uint16_t wLANGID0; |
98 } LANGID_DESCRIPTOR; | 98 } __attribute__ ((packed)) LANGID_DESCRIPTOR; |
99 | 99 |
100 #define D12_SET_ADDRESS_ENABLE 0xD0 | 100 #define D12_SET_ADDRESS_ENABLE 0xD0 |
101 #define D12_SET_ENDPOINT_ENABLE 0xD8 | 101 #define D12_SET_ENDPOINT_ENABLE 0xD8 |
102 #define D12_SET_MODE 0xF3 | 102 #define D12_SET_MODE 0xF3 |
103 #define D12_SET_DMA 0xFB | 103 #define D12_SET_DMA 0xFB |
125 #define D12_INT_EP2_OUT 0x10 | 125 #define D12_INT_EP2_OUT 0x10 |
126 #define D12_INT_EP2_IN 0x20 | 126 #define D12_INT_EP2_IN 0x20 |
127 #define D12_INT_BUS_RESET 0x40 | 127 #define D12_INT_BUS_RESET 0x40 |
128 #define D12_INT_SUSPEND 0x80 | 128 #define D12_INT_SUSPEND 0x80 |
129 | 129 |
130 #define D12_LAST_TRAN_OK 0x01 | |
131 #define D12_LAST_TRAN_ERRMSK 0x1e | |
130 #define D12_LAST_TRAN_SETUP 0x20 | 132 #define D12_LAST_TRAN_SETUP 0x20 |
133 #define D12_LAST_TRAN_DATA 0x40 | |
134 #define D12_LAST_TRAN_OFLOW 0x80 | |
131 | 135 |
132 #define STANDARD_DEVICE_REQUEST 0x00 | 136 #define STANDARD_DEVICE_REQUEST 0x00 |
133 #define STANDARD_INTERFACE_REQUEST 0x01 | 137 #define STANDARD_INTERFACE_REQUEST 0x01 |
134 #define STANDARD_ENDPOINT_REQUEST 0x02 | 138 #define STANDARD_ENDPOINT_REQUEST 0x02 |
135 #define VENDOR_DEVICE_REQUEST 0x40 | 139 #define VENDOR_DEVICE_REQUEST 0x40 |
146 #define SET_CONFIGURATION 9 | 150 #define SET_CONFIGURATION 9 |
147 #define GET_INTERFACE 10 | 151 #define GET_INTERFACE 10 |
148 #define SET_INTERFACE 11 | 152 #define SET_INTERFACE 11 |
149 #define SYNCH_FRAME 12 | 153 #define SYNCH_FRAME 12 |
150 | 154 |
155 #define VENDOR_DOTEMP 125 | |
151 #define VENDOR_UPDATE 126 | 156 #define VENDOR_UPDATE 126 |
152 #define VENDOR_RESET 127 | 157 #define VENDOR_RESET 127 |
153 | 158 |
154 #define ENDPOINT_HALT 0 | 159 #define ENDPOINT_HALT 0 |
155 | 160 |
172 void d12_write_cmd(uint8_t command, const uint8_t *buffer, uint8_t count); | 177 void d12_write_cmd(uint8_t command, const uint8_t *buffer, uint8_t count); |
173 void d12_read_cmd(uint8_t command, uint8_t *buffer, uint8_t count); | 178 void d12_read_cmd(uint8_t command, uint8_t *buffer, uint8_t count); |
174 uint8_t d12_read_endpt(uint8_t endpt, uint8_t *buffer); | 179 uint8_t d12_read_endpt(uint8_t endpt, uint8_t *buffer); |
175 | 180 |
176 void d12_ep0_irq(void); | 181 void d12_ep0_irq(void); |
177 void d12_getdescriptor(USB_SETUP_REQUEST *SetupPacket); | 182 void d12_handle_setup(void); |
178 void d12_stallctrlendpt(void); | 183 void d12_getdescriptor(USB_SETUP_REQUEST *setuppkt); |
184 void d12_stallendpt(uint8_t ep); | |
179 uint8_t d12_read_endpt(uint8_t endpt, uint8_t *buffer); | 185 uint8_t d12_read_endpt(uint8_t endpt, uint8_t *buffer); |
180 void d12_write_endpt(uint8_t endpt, const uint8_t *buffer, uint8_t bytes); | 186 void d12_write_endpt(uint8_t endpt, const uint8_t *buffer, uint8_t bytes); |
181 void d12_write_buffer_ep0(void); | 187 void d12_send_data_ep0(void); |
188 void d12_receive_data_ep1(void); | |
182 void d12_send_data_ep2(void); | 189 void d12_send_data_ep2(void); |
183 void d12_receive_data_ep2(void); | 190 void d12_receive_data_ep2(void); |
184 | 191 |
185 static void reset(void); | 192 static void reset(void); |
186 | 193 |