aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorsago35 <[email protected]>2023-08-02 08:30:51 +0900
committerRon Evans <[email protected]>2023-08-02 09:16:29 +0200
commit395ee2d338d323d0b9225d7522dc419ac40aaaf4 (patch)
tree15b8b904bf1b459b69e97ecee7c29f8077abf188
parent069e4f0d987bef4699c55e84b55c7e5caa3f928c (diff)
downloadtinygo-395ee2d338d323d0b9225d7522dc419ac40aaaf4.tar.gz
tinygo-395ee2d338d323d0b9225d7522dc419ac40aaaf4.zip
machine/usb: refactor endpoint configuration
-rw-r--r--src/machine/usb.go22
-rw-r--r--src/machine/usb/adc/midi/midi.go4
-rw-r--r--src/machine/usb/config.go4
-rw-r--r--src/machine/usb/hid/hid.go4
-rw-r--r--src/machine/usb/hid/joystick/joystick.go6
5 files changed, 20 insertions, 20 deletions
diff --git a/src/machine/usb.go b/src/machine/usb.go
index 823dfdb5f..c28462e53 100644
--- a/src/machine/usb.go
+++ b/src/machine/usb.go
@@ -266,18 +266,18 @@ func EnableCDC(txHandler func(), rxHandler func([]byte), setupHandler func(usb.S
ConfigureUSBEndpoint(usbDescriptor,
[]usb.EndpointConfig{
{
- No: usb.CDC_ENDPOINT_ACM,
- IsIn: true,
- Type: usb.ENDPOINT_TYPE_INTERRUPT,
+ Index: usb.CDC_ENDPOINT_ACM,
+ IsIn: true,
+ Type: usb.ENDPOINT_TYPE_INTERRUPT,
},
{
- No: usb.CDC_ENDPOINT_OUT,
+ Index: usb.CDC_ENDPOINT_OUT,
IsIn: false,
Type: usb.ENDPOINT_TYPE_BULK,
RxHandler: rxHandler,
},
{
- No: usb.CDC_ENDPOINT_IN,
+ Index: usb.CDC_ENDPOINT_IN,
IsIn: true,
Type: usb.ENDPOINT_TYPE_BULK,
TxHandler: txHandler,
@@ -285,7 +285,7 @@ func EnableCDC(txHandler func(), rxHandler func([]byte), setupHandler func(usb.S
},
[]usb.SetupConfig{
{
- No: usb.CDC_ACM_INTERFACE,
+ Index: usb.CDC_ACM_INTERFACE,
Handler: setupHandler,
},
})
@@ -296,19 +296,19 @@ func ConfigureUSBEndpoint(desc descriptor.Descriptor, epSettings []usb.EndpointC
for _, ep := range epSettings {
if ep.IsIn {
- endPoints[ep.No] = uint32(ep.Type | usb.EndpointIn)
+ endPoints[ep.Index] = uint32(ep.Type | usb.EndpointIn)
if ep.TxHandler != nil {
- usbTxHandler[ep.No] = ep.TxHandler
+ usbTxHandler[ep.Index] = ep.TxHandler
}
} else {
- endPoints[ep.No] = uint32(ep.Type | usb.EndpointOut)
+ endPoints[ep.Index] = uint32(ep.Type | usb.EndpointOut)
if ep.RxHandler != nil {
- usbRxHandler[ep.No] = ep.RxHandler
+ usbRxHandler[ep.Index] = ep.RxHandler
}
}
}
for _, s := range setup {
- usbSetupHandler[s.No] = s.Handler
+ usbSetupHandler[s.Index] = s.Handler
}
}
diff --git a/src/machine/usb/adc/midi/midi.go b/src/machine/usb/adc/midi/midi.go
index d0ce3ee1f..30b645ee2 100644
--- a/src/machine/usb/adc/midi/midi.go
+++ b/src/machine/usb/adc/midi/midi.go
@@ -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,
diff --git a/src/machine/usb/config.go b/src/machine/usb/config.go
index de620e7aa..ef7cd3153 100644
--- a/src/machine/usb/config.go
+++ b/src/machine/usb/config.go
@@ -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
}
diff --git a/src/machine/usb/hid/hid.go b/src/machine/usb/hid/hid.go
index 4a17f953a..e73c7a4a2 100644
--- a/src/machine/usb/hid/hid.go
+++ b/src/machine/usb/hid/hid.go
@@ -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,
},
})
diff --git a/src/machine/usb/hid/joystick/joystick.go b/src/machine/usb/hid/joystick/joystick.go
index 18a4d470e..2c2f719c0 100644
--- a/src/machine/usb/hid/joystick/joystick.go
+++ b/src/machine/usb/hid/joystick/joystick.go
@@ -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,
},
},