mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-08 13:03:39 +00:00
machine/usb: refactor endpoint configuration
This commit is contained in:
@@ -44,13 +44,13 @@ func newMidi() *midi {
|
||||
machine.ConfigureUSBEndpoint(descriptor.CDCMIDI,
|
||||
[]usb.EndpointConfig{
|
||||
{
|
||||
No: usb.MIDI_ENDPOINT_OUT,
|
||||
Index: usb.MIDI_ENDPOINT_OUT,
|
||||
IsIn: false,
|
||||
Type: usb.ENDPOINT_TYPE_BULK,
|
||||
RxHandler: m.RxHandler,
|
||||
},
|
||||
{
|
||||
No: usb.MIDI_ENDPOINT_IN,
|
||||
Index: usb.MIDI_ENDPOINT_IN,
|
||||
IsIn: true,
|
||||
Type: usb.ENDPOINT_TYPE_BULK,
|
||||
TxHandler: m.Handler,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package usb
|
||||
|
||||
type EndpointConfig struct {
|
||||
No uint8
|
||||
Index uint8
|
||||
IsIn bool
|
||||
TxHandler func()
|
||||
RxHandler func([]byte)
|
||||
@@ -9,6 +9,6 @@ type EndpointConfig struct {
|
||||
}
|
||||
|
||||
type SetupConfig struct {
|
||||
No uint8
|
||||
Index uint8
|
||||
Handler func(Setup) bool
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ func SetHandler(d hidDevicer) {
|
||||
machine.ConfigureUSBEndpoint(descriptor.CDCHID,
|
||||
[]usb.EndpointConfig{
|
||||
{
|
||||
No: usb.HID_ENDPOINT_IN,
|
||||
Index: usb.HID_ENDPOINT_IN,
|
||||
IsIn: true,
|
||||
Type: usb.ENDPOINT_TYPE_INTERRUPT,
|
||||
TxHandler: handler,
|
||||
@@ -44,7 +44,7 @@ func SetHandler(d hidDevicer) {
|
||||
},
|
||||
[]usb.SetupConfig{
|
||||
{
|
||||
No: usb.HID_INTERFACE,
|
||||
Index: usb.HID_INTERFACE,
|
||||
Handler: setupHandler,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -51,13 +51,13 @@ func UseSettings(def Definitions, rxHandlerFunc func(b []byte), setupFunc func(s
|
||||
machine.ConfigureUSBEndpoint(descriptor.CDCJoystick,
|
||||
[]usb.EndpointConfig{
|
||||
{
|
||||
No: usb.HID_ENDPOINT_OUT,
|
||||
Index: usb.HID_ENDPOINT_OUT,
|
||||
IsIn: false,
|
||||
Type: usb.ENDPOINT_TYPE_INTERRUPT,
|
||||
RxHandler: rxHandlerFunc,
|
||||
},
|
||||
{
|
||||
No: usb.HID_ENDPOINT_IN,
|
||||
Index: usb.HID_ENDPOINT_IN,
|
||||
IsIn: true,
|
||||
Type: usb.ENDPOINT_TYPE_INTERRUPT,
|
||||
TxHandler: js.handler,
|
||||
@@ -65,7 +65,7 @@ func UseSettings(def Definitions, rxHandlerFunc func(b []byte), setupFunc func(s
|
||||
},
|
||||
[]usb.SetupConfig{
|
||||
{
|
||||
No: usb.HID_INTERFACE,
|
||||
Index: usb.HID_INTERFACE,
|
||||
Handler: setupFunc,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user