mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-06-30 20:02:34 +00:00
chore(core/rust): Add micropython::time::sleep
This commit is contained in:
parent
334a143b76
commit
a54ca9cb05
@ -113,6 +113,7 @@ fn generate_micropython_bindings() {
|
|||||||
.allowlist_var("mp_type_TypeError")
|
.allowlist_var("mp_type_TypeError")
|
||||||
// time
|
// time
|
||||||
.allowlist_function("mp_hal_ticks_ms")
|
.allowlist_function("mp_hal_ticks_ms")
|
||||||
|
.allowlist_function("mp_hal_delay_ms")
|
||||||
// typ
|
// typ
|
||||||
.allowlist_var("mp_type_type");
|
.allowlist_var("mp_type_type");
|
||||||
|
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
|
use crate::time::Duration;
|
||||||
|
|
||||||
use super::ffi;
|
use super::ffi;
|
||||||
|
|
||||||
pub fn ticks_ms() -> u32 {
|
pub fn ticks_ms() -> u32 {
|
||||||
unsafe { ffi::mp_hal_ticks_ms() as _ }
|
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 {
|
impl Instant {
|
||||||
pub fn now() -> Self {
|
pub fn now() -> Self {
|
||||||
|
// TODO: We should move this to `micropython::time`.
|
||||||
Self {
|
Self {
|
||||||
millis: time::ticks_ms(),
|
millis: time::ticks_ms(),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user