machine/usb: allow USB Endpoint settings to be changed externally

This commit is contained in:
sago35
2023-08-01 20:22:30 +09:00
committed by Ron Evans
parent d1eb642d45
commit 069e4f0d98
5 changed files with 130 additions and 46 deletions
+18 -1
View File
@@ -3,6 +3,7 @@ package midi
import (
"machine"
"machine/usb"
"machine/usb/descriptor"
)
const (
@@ -40,7 +41,23 @@ func newMidi() *midi {
m := &midi{
buf: NewRingBuffer(),
}
machine.EnableMIDI(m.Handler, m.RxHandler, nil)
machine.ConfigureUSBEndpoint(descriptor.CDCMIDI,
[]usb.EndpointConfig{
{
No: usb.MIDI_ENDPOINT_OUT,
IsIn: false,
Type: usb.ENDPOINT_TYPE_BULK,
RxHandler: m.RxHandler,
},
{
No: usb.MIDI_ENDPOINT_IN,
IsIn: true,
Type: usb.ENDPOINT_TYPE_BULK,
TxHandler: m.Handler,
},
},
[]usb.SetupConfig{},
)
return m
}