mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 10:43:29 +00:00
machine/usb: change to not send before endpoint initialization
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
type USBDevice struct {
|
type USBDevice struct {
|
||||||
initcomplete bool
|
initcomplete bool
|
||||||
|
InitEndpointComplete bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -215,6 +216,7 @@ func handleStandardSetup(setup usb.Setup) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
usbConfiguration = setup.WValueL
|
usbConfiguration = setup.WValueL
|
||||||
|
USBDev.InitEndpointComplete = true
|
||||||
|
|
||||||
SendZlp()
|
SendZlp()
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package keyboard
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"machine"
|
||||||
"machine/usb/hid"
|
"machine/usb/hid"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -91,12 +92,14 @@ func (kb *keyboard) Handler() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (kb *keyboard) tx(b []byte) {
|
func (kb *keyboard) tx(b []byte) {
|
||||||
|
if machine.USBDev.InitEndpointComplete {
|
||||||
if kb.waitTxc {
|
if kb.waitTxc {
|
||||||
kb.buf.Put(b)
|
kb.buf.Put(b)
|
||||||
} else {
|
} else {
|
||||||
kb.waitTxc = true
|
kb.waitTxc = true
|
||||||
hid.SendUSBPacket(b)
|
hid.SendUSBPacket(b)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (kb *keyboard) ready() bool {
|
func (kb *keyboard) ready() bool {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package mouse
|
package mouse
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"machine"
|
||||||
"machine/usb/hid"
|
"machine/usb/hid"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -55,12 +56,14 @@ func (m *mouse) Handler() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *mouse) tx(b []byte) {
|
func (m *mouse) tx(b []byte) {
|
||||||
|
if machine.USBDev.InitEndpointComplete {
|
||||||
if m.waitTxc {
|
if m.waitTxc {
|
||||||
m.buf.Put(b)
|
m.buf.Put(b)
|
||||||
} else {
|
} else {
|
||||||
m.waitTxc = true
|
m.waitTxc = true
|
||||||
hid.SendUSBPacket(b)
|
hid.SendUSBPacket(b)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move is a function that moves the mouse cursor.
|
// Move is a function that moves the mouse cursor.
|
||||||
|
|||||||
@@ -76,12 +76,14 @@ func (m *Joystick) rxHandler(b []byte) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Joystick) tx(b []byte) {
|
func (m *Joystick) tx(b []byte) {
|
||||||
|
if machine.USBDev.InitEndpointComplete {
|
||||||
if m.waitTxc {
|
if m.waitTxc {
|
||||||
m.buf.Put(b)
|
m.buf.Put(b)
|
||||||
} else {
|
} else {
|
||||||
m.waitTxc = true
|
m.waitTxc = true
|
||||||
m.sendUSBPacket(b)
|
m.sendUSBPacket(b)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// to InterruptOut
|
// to InterruptOut
|
||||||
|
|||||||
@@ -71,12 +71,14 @@ func (m *midi) Handler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *midi) tx(b []byte) {
|
func (m *midi) tx(b []byte) {
|
||||||
|
if machine.USBDev.InitEndpointComplete {
|
||||||
if m.waitTxc {
|
if m.waitTxc {
|
||||||
m.buf.Put(b)
|
m.buf.Put(b)
|
||||||
} else {
|
} else {
|
||||||
m.waitTxc = true
|
m.waitTxc = true
|
||||||
m.sendUSBPacket(b)
|
m.sendUSBPacket(b)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// from BulkOut
|
// from BulkOut
|
||||||
|
|||||||
Reference in New Issue
Block a user