summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-12-04 00:47:20 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-12-04 00:47:20 +0300
commit1779a62085b287f10a02843feabc07d431671227 (patch)
tree225615e9645d8060cca16d8f69147d59e35bc681
parent46e59c52afe60d1c345df62158b2e5b6c64e9146 (diff)
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.
-rw-r--r--zephyr/modutime.c2
-rw-r--r--zephyr/mphalport.h8
2 files changed, 4 insertions, 6 deletions
diff --git a/zephyr/modutime.c b/zephyr/modutime.c
index 8b96a5ab1..378068bb3 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 fafbb9ebe..e3cca8d37 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) {