circuitpython/zephyr/mphalport.h
Paul Sokolovsky 3cdccb9b14 zephyr: Fix mp_hal_set_interrupt_char() declaration to be compatible.
With other ports. Other ports declare it in mphalport.h, it can be
inline or macro.
2016-10-26 17:53:28 +03:00

28 lines
763 B
C

#include <zephyr.h>
#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;
}
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;
}
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();
}
static inline void mp_hal_delay_us(mp_uint_t delay) {
task_sleep(USEC(delay));
}
static inline void mp_hal_delay_ms(mp_uint_t delay) {
task_sleep(MSEC(delay));
}