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 {
initcomplete bool
InitEndpointComplete bool
}
var (
@ -215,6 +216,7 @@ func handleStandardSetup(setup usb.Setup) bool {
}
usbConfiguration = setup.WValueL
USBDev.InitEndpointComplete = true
SendZlp()
return true

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

@ -2,6 +2,7 @@ package keyboard
import (
"errors"
"machine"
"machine/usb/hid"
)
@ -91,6 +92,7 @@ func (kb *keyboard) Handler() bool {
}
func (kb *keyboard) tx(b []byte) {
if machine.USBDev.InitEndpointComplete {
if kb.waitTxc {
kb.buf.Put(b)
} else {
@ -98,6 +100,7 @@ func (kb *keyboard) tx(b []byte) {
hid.SendUSBPacket(b)
}
}
}
func (kb *keyboard) ready() bool {
return true

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

@ -1,6 +1,7 @@
package mouse
import (
"machine"
"machine/usb/hid"
)
@ -55,6 +56,7 @@ func (m *mouse) Handler() bool {
}
func (m *mouse) tx(b []byte) {
if machine.USBDev.InitEndpointComplete {
if m.waitTxc {
m.buf.Put(b)
} else {
@ -62,6 +64,7 @@ func (m *mouse) tx(b []byte) {
hid.SendUSBPacket(b)
}
}
}
// Move is a function that moves the mouse cursor.
func (m *mouse) Move(vx, vy int) {

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

@ -76,6 +76,7 @@ func (m *Joystick) rxHandler(b []byte) {
}
func (m *Joystick) tx(b []byte) {
if machine.USBDev.InitEndpointComplete {
if m.waitTxc {
m.buf.Put(b)
} else {
@ -83,6 +84,7 @@ func (m *Joystick) tx(b []byte) {
m.sendUSBPacket(b)
}
}
}
// to InterruptOut
func (m *Joystick) SendReport(reportID byte, b []byte) {

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

@ -71,6 +71,7 @@ func (m *midi) Handler() {
}
func (m *midi) tx(b []byte) {
if machine.USBDev.InitEndpointComplete {
if m.waitTxc {
m.buf.Put(b)
} else {
@ -78,6 +79,7 @@ func (m *midi) tx(b []byte) {
m.sendUSBPacket(b)
}
}
}
// from BulkOut
func (m *midi) RxHandler(b []byte) {