Skip to content

Commit 395ee2d

Browse files
sago35deadprogram
authored andcommitted
machine/usb: refactor endpoint configuration
1 parent 069e4f0 commit 395ee2d

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

src/machine/usb.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -266,26 +266,26 @@ func EnableCDC(txHandler func(), rxHandler func([]byte), setupHandler func(usb.S
266266
ConfigureUSBEndpoint(usbDescriptor,
267267
[]usb.EndpointConfig{
268268
{
269-
No: usb.CDC_ENDPOINT_ACM,
270-
IsIn: true,
271-
Type: usb.ENDPOINT_TYPE_INTERRUPT,
269+
Index: usb.CDC_ENDPOINT_ACM,
270+
IsIn: true,
271+
Type: usb.ENDPOINT_TYPE_INTERRUPT,
272272
},
273273
{
274-
No: usb.CDC_ENDPOINT_OUT,
274+
Index: usb.CDC_ENDPOINT_OUT,
275275
IsIn: false,
276276
Type: usb.ENDPOINT_TYPE_BULK,
277277
RxHandler: rxHandler,
278278
},
279279
{
280-
No: usb.CDC_ENDPOINT_IN,
280+
Index: usb.CDC_ENDPOINT_IN,
281281
IsIn: true,
282282
Type: usb.ENDPOINT_TYPE_BULK,
283283
TxHandler: txHandler,
284284
},
285285
},
286286
[]usb.SetupConfig{
287287
{
288-
No: usb.CDC_ACM_INTERFACE,
288+
Index: usb.CDC_ACM_INTERFACE,
289289
Handler: setupHandler,
290290
},
291291
})
@@ -296,19 +296,19 @@ func ConfigureUSBEndpoint(desc descriptor.Descriptor, epSettings []usb.EndpointC
296296

297297
for _, ep := range epSettings {
298298
if ep.IsIn {
299-
endPoints[ep.No] = uint32(ep.Type | usb.EndpointIn)
299+
endPoints[ep.Index] = uint32(ep.Type | usb.EndpointIn)
300300
if ep.TxHandler != nil {
301-
usbTxHandler[ep.No] = ep.TxHandler
301+
usbTxHandler[ep.Index] = ep.TxHandler
302302
}
303303
} else {
304-
endPoints[ep.No] = uint32(ep.Type | usb.EndpointOut)
304+
endPoints[ep.Index] = uint32(ep.Type | usb.EndpointOut)
305305
if ep.RxHandler != nil {
306-
usbRxHandler[ep.No] = ep.RxHandler
306+
usbRxHandler[ep.Index] = ep.RxHandler
307307
}
308308
}
309309
}
310310

311311
for _, s := range setup {
312-
usbSetupHandler[s.No] = s.Handler
312+
usbSetupHandler[s.Index] = s.Handler
313313
}
314314
}

src/machine/usb/adc/midi/midi.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ func newMidi() *midi {
4444
machine.ConfigureUSBEndpoint(descriptor.CDCMIDI,
4545
[]usb.EndpointConfig{
4646
{
47-
No: usb.MIDI_ENDPOINT_OUT,
47+
Index: usb.MIDI_ENDPOINT_OUT,
4848
IsIn: false,
4949
Type: usb.ENDPOINT_TYPE_BULK,
5050
RxHandler: m.RxHandler,
5151
},
5252
{
53-
No: usb.MIDI_ENDPOINT_IN,
53+
Index: usb.MIDI_ENDPOINT_IN,
5454
IsIn: true,
5555
Type: usb.ENDPOINT_TYPE_BULK,
5656
TxHandler: m.Handler,

src/machine/usb/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package usb
22

33
type EndpointConfig struct {
4-
No uint8
4+
Index uint8
55
IsIn bool
66
TxHandler func()
77
RxHandler func([]byte)
88
Type uint8
99
}
1010

1111
type SetupConfig struct {
12-
No uint8
12+
Index uint8
1313
Handler func(Setup) bool
1414
}

src/machine/usb/hid/hid.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ func SetHandler(d hidDevicer) {
3636
machine.ConfigureUSBEndpoint(descriptor.CDCHID,
3737
[]usb.EndpointConfig{
3838
{
39-
No: usb.HID_ENDPOINT_IN,
39+
Index: usb.HID_ENDPOINT_IN,
4040
IsIn: true,
4141
Type: usb.ENDPOINT_TYPE_INTERRUPT,
4242
TxHandler: handler,
4343
},
4444
},
4545
[]usb.SetupConfig{
4646
{
47-
No: usb.HID_INTERFACE,
47+
Index: usb.HID_INTERFACE,
4848
Handler: setupHandler,
4949
},
5050
})

src/machine/usb/hid/joystick/joystick.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,21 @@ func UseSettings(def Definitions, rxHandlerFunc func(b []byte), setupFunc func(s
5151
machine.ConfigureUSBEndpoint(descriptor.CDCJoystick,
5252
[]usb.EndpointConfig{
5353
{
54-
No: usb.HID_ENDPOINT_OUT,
54+
Index: usb.HID_ENDPOINT_OUT,
5555
IsIn: false,
5656
Type: usb.ENDPOINT_TYPE_INTERRUPT,
5757
RxHandler: rxHandlerFunc,
5858
},
5959
{
60-
No: usb.HID_ENDPOINT_IN,
60+
Index: usb.HID_ENDPOINT_IN,
6161
IsIn: true,
6262
Type: usb.ENDPOINT_TYPE_INTERRUPT,
6363
TxHandler: js.handler,
6464
},
6565
},
6666
[]usb.SetupConfig{
6767
{
68-
No: usb.HID_INTERFACE,
68+
Index: usb.HID_INTERFACE,
6969
Handler: setupFunc,
7070
},
7171
},

0 commit comments

Comments
 (0)