From 54cf898d6483eddc11ccc2a2c7a30a5bd01a4e2c Mon Sep 17 00:00:00 2001 From: Nicolas Stalder Date: Sun, 2 May 2021 18:43:52 +0200 Subject: [PATCH] Simplify time handling, Solo 2 --- Cargo.toml | 1 + src/class.rs | 6 +++--- src/types.rs | 5 ++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3e430e8..8a0b3f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ edition = "2018" [dependencies] apdu-dispatch = { git = "https://github.com/solokeys/apdu-dispatch", branch = "main" } delog = "0.1.0" +embedded-time = "0.10.1" heapless = "0.6" heapless-bytes = "0.2.0" interchange = "0.2.0" diff --git a/src/class.rs b/src/class.rs index ad13809..87c97bd 100644 --- a/src/class.rs +++ b/src/class.rs @@ -1,6 +1,6 @@ use core::convert::TryFrom; -use core::time::Duration; +use embedded_time::duration::Extensions; use interchange::Requester; use apdu_dispatch::interchanges; @@ -57,7 +57,7 @@ where pub fn did_start_processing(&mut self) -> Status { if self.pipe.did_started_processing() { // We should send a wait extension later - Status::ReceivedData(Duration::from_millis(1000)) + Status::ReceivedData(1_000.milliseconds()) } else { Status::Idle } @@ -66,7 +66,7 @@ where pub fn send_wait_extension (&mut self) -> Status { if self.pipe.send_wait_extension() { // We should send another wait extension later - Status::ReceivedData(Duration::from_millis(1000)) + Status::ReceivedData(1_000.milliseconds()) } else { Status::Idle } diff --git a/src/types.rs b/src/types.rs index 1c95780..3e2e324 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,5 +1,4 @@ -// use cortex_m_semihosting::hprintln; -use core::time::Duration; +use embedded_time::duration::Milliseconds; // pub mod apdu; pub mod packet; @@ -16,7 +15,7 @@ pub enum ClassRequest { pub enum Status { Idle, - ReceivedData(Duration), + ReceivedData(Milliseconds), } impl core::convert::TryFrom for ClassRequest {