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:
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…
Reference in New Issue
Block a user