summaryrefslogtreecommitdiff
path: root/shared-module/usb_hid
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2019-11-18 08:22:41 -0600
committerJeff Epler <jepler@gmail.com>2019-11-18 11:01:23 -0600
commit7f744a2369a5036cadfa05575da1704f709c98bb (patch)
tree62b0c1d21d75910076a6c4b8d11a0c55861267aa /shared-module/usb_hid
parent45d1b290ee13ee4080e9718909c33053583314b8 (diff)
Supervisor: move most of systick to the supervisor
This code is shared by most parts, except where not all the #ifdefs inside the tick function were present in all ports. This mostly would have broken gamepad tick support on non-samd ports. The "ms32" and "ms64" variants of the tick functions are introduced because there is no 64-bit atomic read. Disabling interrupts avoids a low probability bug where milliseconds could be off by ~49.5 days once every ~49.5 days (2^32 ms). Avoiding disabling interrupts when only the low 32 bits are needed is a minor optimization. Testing performed: on metro m4 express, USB still works and time.monotonic_ns() still counts up
Diffstat (limited to 'shared-module/usb_hid')
-rw-r--r--shared-module/usb_hid/Device.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/shared-module/usb_hid/Device.c b/shared-module/usb_hid/Device.c
index bed7d163f..8744f2ed3 100644
--- a/shared-module/usb_hid/Device.c
+++ b/shared-module/usb_hid/Device.c
@@ -30,6 +30,7 @@
#include "shared-bindings/usb_hid/Device.h"
#include "shared-module/usb_hid/Device.h"
#include "supervisor/shared/translate.h"
+#include "supervisor/shared/tick.h"
#include "tusb.h"
uint8_t common_hal_usb_hid_device_get_usage_page(usb_hid_device_obj_t *self) {
@@ -46,8 +47,8 @@ void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t*
}
// Wait until interface is ready, timeout = 2 seconds
- uint64_t end_ticks = ticks_ms + 2000;
- while ( (ticks_ms < end_ticks) && !tud_hid_ready() ) {
+ uint64_t end_ticks = supervisor_ticks_ms64() + 2000;
+ while ( (supervisor_ticks_ms64() < end_ticks) && !tud_hid_ready() ) {
RUN_BACKGROUND_TASKS;
}