diff options
-rw-r--r-- | zephyr/modutime.c | 2 | ||||
-rw-r--r-- | zephyr/mphalport.h | 8 |
2 files changed, 4 insertions, 6 deletions
diff --git a/zephyr/modutime.c b/zephyr/modutime.c index 8b96a5ab1e..378068bb38 100644 --- a/zephyr/modutime.c +++ b/zephyr/modutime.c @@ -40,7 +40,7 @@ STATIC mp_obj_t mod_time_time(void) { * single precision floats so the fraction component will start to * lose precision on devices with a long uptime. */ - return mp_obj_new_int(sys_tick_get() / sys_clock_ticks_per_sec); + return mp_obj_new_int(k_uptime_get() / 1000); } STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_time_time_obj, mod_time_time); diff --git a/zephyr/mphalport.h b/zephyr/mphalport.h index fafbb9ebe5..e3cca8d37d 100644 --- a/zephyr/mphalport.h +++ b/zephyr/mphalport.h @@ -2,20 +2,18 @@ #include "lib/utils/interrupt_char.h" static inline mp_uint_t mp_hal_ticks_us(void) { - return sys_tick_get() * sys_clock_us_per_tick; + return SYS_CLOCK_HW_CYCLES_TO_NS(k_cycle_get_32()) / 1000; } static inline mp_uint_t mp_hal_ticks_ms(void) { - int64_t us = sys_tick_get() * sys_clock_us_per_tick; - mp_int_t ms = us / 1000; - return ms; + return k_uptime_get(); } static inline mp_uint_t mp_hal_ticks_cpu(void) { // ticks_cpu() is defined as using the highest-resolution timing source // in the system. This is usually a CPU clock, but doesn't have to be, // here we just use Zephyr hi-res timer. - return sys_cycle_get_32(); + return k_cycle_get_32(); } static inline void mp_hal_delay_us(mp_uint_t delay) { |