diff options
| author | Jeff Epler <jepler@gmail.com> | 2019-11-18 08:22:41 -0600 |
|---|---|---|
| committer | Jeff Epler <jepler@gmail.com> | 2019-11-18 11:01:23 -0600 |
| commit | 7f744a2369a5036cadfa05575da1704f709c98bb (patch) | |
| tree | 62b0c1d21d75910076a6c4b8d11a0c55861267aa /shared-module/network | |
| parent | 45d1b290ee13ee4080e9718909c33053583314b8 (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/network')
| -rw-r--r-- | shared-module/network/__init__.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/shared-module/network/__init__.c b/shared-module/network/__init__.c index 96648b260..925e9a2a3 100644 --- a/shared-module/network/__init__.c +++ b/shared-module/network/__init__.c @@ -31,6 +31,8 @@ #include "py/mphal.h" #include "py/mperrno.h" +#include "supervisor/shared/tick.h" + #include "shared-bindings/random/__init__.h" #include "shared-module/network/__init__.h" @@ -53,7 +55,7 @@ void network_module_deinit(void) { void network_module_background(void) { static uint32_t next_tick = 0; - uint32_t this_tick = ticks_ms; + uint32_t this_tick = supervisor_ticks_ms32(); if (this_tick < next_tick) return; next_tick = this_tick + 1000; |
