aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/machine/usb/hid/hid.go
diff options
context:
space:
mode:
authorsago35 <[email protected]>2022-07-10 18:33:52 +0900
committerGitHub <[email protected]>2022-07-10 11:33:52 +0200
commitd434058aefffeb450d71313f7144a82eceba60c8 (patch)
treea066d0742e9f9fc71ce5db2fbbac09749f1ec630 /src/machine/usb/hid/hid.go
parent56780c26917647900bda67018a22c962bce2333a (diff)
downloadtinygo-d434058aefffeb450d71313f7144a82eceba60c8.tar.gz
tinygo-d434058aefffeb450d71313f7144a82eceba60c8.zip
samd21,samd51,nrf52840: move usbcdc to machine/usb/cdc (#2972)
* samd21,samd51,nrf52840: move usbcdc to machine/usb/cdc
Diffstat (limited to 'src/machine/usb/hid/hid.go')
-rw-r--r--src/machine/usb/hid/hid.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/machine/usb/hid/hid.go b/src/machine/usb/hid/hid.go
index fd9317511..1429dab2b 100644
--- a/src/machine/usb/hid/hid.go
+++ b/src/machine/usb/hid/hid.go
@@ -14,6 +14,9 @@ var (
const (
hidEndpoint = 4
+
+ usb_SET_REPORT_TYPE = 33
+ usb_SET_IDLE = 10
)
type hidDevicer interface {
@@ -27,7 +30,7 @@ var size int
// calls machine.EnableHID for USB configuration
func SetCallbackHandler(d hidDevicer) {
if size == 0 {
- machine.EnableHID(callback)
+ machine.EnableHID(callback, nil, callbackSetup)
}
devices[size] = d
@@ -45,7 +48,16 @@ func callback() {
}
}
+func callbackSetup(setup machine.USBSetup) bool {
+ ok := false
+ if setup.BmRequestType == usb_SET_REPORT_TYPE && setup.BRequest == usb_SET_IDLE {
+ machine.SendZlp()
+ ok = true
+ }
+ return ok
+}
+
// SendUSBPacket sends a HIDPacket.
func SendUSBPacket(b []byte) {
- machine.SendUSBHIDPacket(hidEndpoint, b)
+ machine.SendUSBInPacket(hidEndpoint, b)
}