mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-08 04:56:43 +00:00
redo ticktimer/trng to use the new convenience functions
This commit is contained in:
parent
3c34517632
commit
68b9addd45
2 changed files with 10 additions and 18 deletions
|
|
@ -19,11 +19,9 @@ impl Ticktimer {
|
|||
/// note special case for elapsed_ms() is "infalliable". it really should never fail so get rid of the Error
|
||||
pub fn elapsed_ms(&self) -> u64 {
|
||||
let response = send_message(self.conn,
|
||||
xous::Message::BlockingScalar(xous::ScalarMessage {
|
||||
id: api::Opcode::ElapsedMs.to_usize().unwrap(),
|
||||
arg1: 0, arg2: 0, arg3: 0, arg4: 0
|
||||
})
|
||||
).expect("Ticktimer: failure to send message to Ticktimer");
|
||||
xous::Message::new_blocking_scalar(api::Opcode::ElapsedMs.to_usize().unwrap(),
|
||||
0, 0, 0, 0,
|
||||
)).expect("Ticktimer: failure to send message to Ticktimer");
|
||||
if let xous::Result::Scalar2(upper, lower) = response {
|
||||
upper as u64 | ((lower as u64) << 32)
|
||||
} else {
|
||||
|
|
@ -33,11 +31,9 @@ impl Ticktimer {
|
|||
|
||||
pub fn sleep_ms(&self, ms: usize) -> Result<(), Error> {
|
||||
send_message(self.conn,
|
||||
xous::Message::BlockingScalar(xous::ScalarMessage {
|
||||
id: api::Opcode::SleepMs.to_usize().unwrap(),
|
||||
arg1: ms,
|
||||
arg2: 0, arg3: 0, arg4: 0
|
||||
})
|
||||
xous::Message::new_blocking_scalar(api::Opcode::SleepMs.to_usize().unwrap(),
|
||||
ms,
|
||||
0, 0, 0)
|
||||
).map(|_| ())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,10 +16,8 @@ impl Trng {
|
|||
}
|
||||
pub fn get_u32(&self) -> Result<u32, xous::Error> {
|
||||
let response = send_message(self.conn,
|
||||
xous::Message::BlockingScalar(xous::ScalarMessage {
|
||||
id: api::Opcode::GetTrng.to_usize().unwrap(),
|
||||
arg1: 1 /* count */, arg2: 0, arg3: 0, arg4: 0
|
||||
})
|
||||
xous::Message::new_blocking_scalar(api::Opcode::GetTrng.to_usize().unwrap(),
|
||||
1 /* count */, 0, 0, 0, )
|
||||
).expect("TRNG|LIB: can't get_u32");
|
||||
if let xous::Result::Scalar2(trng, _) = response {
|
||||
Ok(trng as u32)
|
||||
|
|
@ -29,10 +27,8 @@ impl Trng {
|
|||
}
|
||||
pub fn get_u64(&self) -> Result<u64, xous::Error> {
|
||||
let response = send_message(self.conn,
|
||||
xous::Message::BlockingScalar(xous::ScalarMessage {
|
||||
id: api::Opcode::GetTrng.to_usize().unwrap(),
|
||||
arg1: 2 /* count */, arg2: 0, arg3: 0, arg4: 0
|
||||
})
|
||||
xous::Message::new_blocking_scalar(api::Opcode::GetTrng.to_usize().unwrap(),
|
||||
2 /* count */, 0, 0, 0, )
|
||||
).expect("TRNG|LIB: can't get_u32");
|
||||
if let xous::Result::Scalar2(lo, hi) = response {
|
||||
Ok( lo as u64 | ((hi as u64) << 32) )
|
||||
|
|
|
|||
Loading…
Reference in a new issue