diff --git a/core/embed/rust/build.rs b/core/embed/rust/build.rs index 9898f6cc1..0ed9985c1 100644 --- a/core/embed/rust/build.rs +++ b/core/embed/rust/build.rs @@ -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"); diff --git a/core/embed/rust/src/micropython/time.rs b/core/embed/rust/src/micropython/time.rs index 026ba1796..3f6916b68 100644 --- a/core/embed/rust/src/micropython/time.rs +++ b/core/embed/rust/src/micropython/time.rs @@ -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 _) } +} diff --git a/core/embed/rust/src/time.rs b/core/embed/rust/src/time.rs index 7b8eeacef..e2ea3d922 100644 --- a/core/embed/rust/src/time.rs +++ b/core/embed/rust/src/time.rs @@ -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(), }