Commit 1779a620 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

zephyr: Switch to Zephyr 1.6 unified kernel API.

In 1.6, Zephyr switched to "unified kernel" and new API set. Older kernel
API is supported, but marked as deprecated and leads to warnings.
parent 46e59c52
......@@ -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);
......@@ -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) {
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment