Skip to content

Commit a1a9e57

Browse files
koltendpgeorge
authored andcommitted
usb-device-hid: Enable configuring the bInterval on hid devices.
By using the new `interval_ms` argument. Signed-off-by: kolten <koltenpearson@fastmail.com>
1 parent 8380c7b commit a1a9e57

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
metadata(version="0.1.2")
1+
metadata(version="0.2.0")
22
require("usb-device")
33
package("usb")

micropython/usb/usb-device-hid/usb/device/hid.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def __init__(
6464
set_report_buf=None,
6565
protocol=_INTERFACE_PROTOCOL_NONE,
6666
interface_str=None,
67+
interval_ms=8,
6768
):
6869
# Construct a new HID interface.
6970
#
@@ -85,12 +86,15 @@ def __init__(
8586
# - protocol can be set to a specific value as per HID v1.11 section 4.3 Protocols, p9.
8687
#
8788
# - interface_str is an optional string descriptor to associate with the HID USB interface.
89+
#
90+
# - interval_ms this is the polling rate the device will request the host use in milliseconds.
8891
super().__init__()
8992
self.report_descriptor = report_descriptor
9093
self.extra_descriptors = extra_descriptors
9194
self._set_report_buf = set_report_buf
9295
self.protocol = protocol
9396
self.interface_str = interface_str
97+
self.interval_ms = interval_ms
9498

9599
self._int_ep = None # set during enumeration
96100

@@ -150,7 +154,7 @@ def desc_cfg(self, desc, itf_num, ep_num, strs):
150154
# Add the typical single USB interrupt endpoint descriptor associated
151155
# with a HID interface.
152156
self._int_ep = ep_num | _EP_IN_FLAG
153-
desc.endpoint(self._int_ep, "interrupt", 8, 8)
157+
desc.endpoint(self._int_ep, "interrupt", 8, self.interval_ms)
154158

155159
self.idle_rate = 0
156160

0 commit comments

Comments
 (0)