@@ -119,11 +119,29 @@ var udd_ep_out_cache_buffer [NumberOfUSBEndpoints][64]uint8
119119// must be revisited.
120120var usb_trans_buffer [255 ]uint8
121121
122+ const NumberOfUSBEndpoints = max (len (inEndpoints ), len (outEndpoints ))
123+
122124var (
123125 usbTxHandler [NumberOfUSBEndpoints ]func ()
124126 usbRxHandler [NumberOfUSBEndpoints ]func ([]byte ) bool
125127 usbSetupHandler [usb .NumberOfInterfaces ]func (usb.Setup ) bool
126128 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+ }
127145)
128146
129147// sendDescriptor creates and sends the various USB descriptor types that
@@ -202,7 +220,7 @@ func handleStandardSetup(setup usb.Setup) bool {
202220 if setup .WValueL == 1 { // DEVICEREMOTEWAKEUP
203221 isRemoteWakeUpEnabled = false
204222 } 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 {
206224 // Host has requested to clear an endpoint stall. If the request is addressed to
207225 // an endpoint with a configured StallHandler, forward the message on.
208226 // The 0x7F mask is used to clear the direction bit from the endpoint number
@@ -217,7 +235,7 @@ func handleStandardSetup(setup usb.Setup) bool {
217235 if setup .WValueL == 1 { // DEVICEREMOTEWAKEUP
218236 isRemoteWakeUpEnabled = true
219237 } 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 {
221239 // Host has requested to stall an endpoint. If the request is addressed to
222240 // an endpoint with a configured StallHandler, forward the message on.
223241 // The 0x7F mask is used to clear the direction bit from the endpoint number
0 commit comments