You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
685 B
26 lines
685 B
8 years ago
|
#include <zephyr.h>
|
||
8 years ago
|
#include "lib/utils/interrupt_char.h"
|
||
8 years ago
|
|
||
|
static inline mp_uint_t mp_hal_ticks_us(void) {
|
||
8 years ago
|
return SYS_CLOCK_HW_CYCLES_TO_NS(k_cycle_get_32()) / 1000;
|
||
8 years ago
|
}
|
||
|
|
||
|
static inline mp_uint_t mp_hal_ticks_ms(void) {
|
||
8 years ago
|
return k_uptime_get();
|
||
8 years ago
|
}
|
||
|
|
||
|
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.
|
||
8 years ago
|
return k_cycle_get_32();
|
||
8 years ago
|
}
|
||
|
|
||
|
static inline void mp_hal_delay_us(mp_uint_t delay) {
|
||
8 years ago
|
k_busy_wait(delay);
|
||
8 years ago
|
}
|
||
|
|
||
|
static inline void mp_hal_delay_ms(mp_uint_t delay) {
|
||
8 years ago
|
k_sleep(delay);
|
||
8 years ago
|
}
|