machine/usb: change to not send before endpoint initialization

Этот коммит содержится в:
sago35 2023-01-08 11:59:26 +09:00 коммит произвёл Ron Evans
родитель a7ff2731b9
коммит 5f3534fe72
5 изменённых файлов: 33 добавлений и 21 удалений

Просмотреть файл

@ -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