@@ -119,11 +119,29 @@ var udd_ep_out_cache_buffer [NumberOfUSBEndpoints][64]uint8
119
119
// must be revisited.
120
120
var usb_trans_buffer [255 ]uint8
121
121
122
+ const NumberOfUSBEndpoints = max (len (inEndpoints ), len (outEndpoints ))
123
+
122
124
var (
123
125
usbTxHandler [NumberOfUSBEndpoints ]func ()
124
126
usbRxHandler [NumberOfUSBEndpoints ]func ([]byte ) bool
125
127
usbSetupHandler [usb .NumberOfInterfaces ]func (usb.Setup ) bool
126
128
usbStallHandler [NumberOfUSBEndpoints ]func (usb.Setup ) bool
129
+
130
+ inEndpoints = [... ]uint32 {
131
+ usb .CONTROL_ENDPOINT : usb .ENDPOINT_TYPE_CONTROL ,
132
+ usb .CDC_ENDPOINT_ACM : (usb .ENDPOINT_TYPE_INTERRUPT | usb .EndpointIn ),
133
+ usb .CDC_ENDPOINT_IN : (usb .ENDPOINT_TYPE_BULK | usb .EndpointIn ),
134
+ usb .HID_ENDPOINT_IN : (usb .ENDPOINT_TYPE_DISABLE ), // Interrupt In
135
+ usb .MIDI_ENDPOINT_IN : (usb .ENDPOINT_TYPE_DISABLE ), // Bulk In
136
+ usb .MSC_ENDPOINT_IN : (usb .ENDPOINT_TYPE_DISABLE ), // Bulk In
137
+ }
138
+ outEndpoints = [... ]uint32 {
139
+ usb .CONTROL_ENDPOINT : usb .ENDPOINT_TYPE_CONTROL ,
140
+ usb .CDC_ENDPOINT_OUT : (usb .ENDPOINT_TYPE_BULK | usb .EndpointOut ),
141
+ usb .HID_ENDPOINT_OUT : (usb .ENDPOINT_TYPE_DISABLE ), // Interrupt Out
142
+ usb .MIDI_ENDPOINT_OUT : (usb .ENDPOINT_TYPE_DISABLE ), // Bulk Out
143
+ usb .MSC_ENDPOINT_OUT : (usb .ENDPOINT_TYPE_DISABLE ), // Bulk Out
144
+ }
127
145
)
128
146
129
147
// sendDescriptor creates and sends the various USB descriptor types that
@@ -202,7 +220,7 @@ func handleStandardSetup(setup usb.Setup) bool {
202
220
if setup .WValueL == 1 { // DEVICEREMOTEWAKEUP
203
221
isRemoteWakeUpEnabled = false
204
222
} else if setup .WValueL == 0 { // ENDPOINTHALT
205
- if idx := setup .WIndex & 0x7F ; idx < NumberOfUSBEndpoints && usbStallHandler [idx ] != nil {
223
+ if idx := setup .WIndex & 0x7F ; idx < uint16 ( NumberOfUSBEndpoints ) && usbStallHandler [idx ] != nil {
206
224
// Host has requested to clear an endpoint stall. If the request is addressed to
207
225
// an endpoint with a configured StallHandler, forward the message on.
208
226
// The 0x7F mask is used to clear the direction bit from the endpoint number
@@ -217,7 +235,7 @@ func handleStandardSetup(setup usb.Setup) bool {
217
235
if setup .WValueL == 1 { // DEVICEREMOTEWAKEUP
218
236
isRemoteWakeUpEnabled = true
219
237
} else if setup .WValueL == 0 { // ENDPOINTHALT
220
- if idx := setup .WIndex & 0x7F ; idx < NumberOfUSBEndpoints && usbStallHandler [idx ] != nil {
238
+ if idx := setup .WIndex & 0x7F ; idx < uint16 ( NumberOfUSBEndpoints ) && usbStallHandler [idx ] != nil {
221
239
// Host has requested to stall an endpoint. If the request is addressed to
222
240
// an endpoint with a configured StallHandler, forward the message on.
223
241
// The 0x7F mask is used to clear the direction bit from the endpoint number
0 commit comments