1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 23:48:12 +00:00

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

This commit is contained in:
Jan Pochyla 2021-11-26 19:40:35 +01:00 committed by matejcik
parent 334a143b76
commit a54ca9cb05
3 changed files with 8 additions and 0 deletions

View File

@ -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");

View File

@ -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 _) }
}

View File

@ -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(),
}