chore(core/rust): Add micropython::time::sleep

pull/1961/head
Jan Pochyla 3 years ago committed by matejcik
parent 334a143b76
commit a54ca9cb05

@ -113,6 +113,7 @@ fn generate_micropython_bindings() {
.allowlist_var("mp_type_TypeError")
// time
.allowlist_function("mp_hal_ticks_ms")
.allowlist_function("mp_hal_delay_ms")
// typ
.allowlist_var("mp_type_type");

@ -1,5 +1,11 @@
use crate::time::Duration;
use super::ffi;
pub fn ticks_ms() -> u32 {
unsafe { ffi::mp_hal_ticks_ms() as _ }
}
pub fn sleep(delay: Duration) {
unsafe { ffi::mp_hal_delay_ms(delay.to_millis() as _) }
}

@ -67,6 +67,7 @@ pub struct Instant {
impl Instant {
pub fn now() -> Self {
// TODO: We should move this to `micropython::time`.
Self {
millis: time::ticks_ms(),
}

Loading…
Cancel
Save