mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +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
|
/// 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 {
|
pub fn elapsed_ms(&self) -> u64 {
|
||||||
let response = send_message(self.conn,
|
let response = send_message(self.conn,
|
||||||
xous::Message::BlockingScalar(xous::ScalarMessage {
|
xous::Message::new_blocking_scalar(api::Opcode::ElapsedMs.to_usize().unwrap(),
|
||||||
id: api::Opcode::ElapsedMs.to_usize().unwrap(),
|
0, 0, 0, 0,
|
||||||
arg1: 0, arg2: 0, arg3: 0, arg4: 0
|
)).expect("Ticktimer: failure to send message to Ticktimer");
|
||||||
})
|
|
||||||
).expect("Ticktimer: failure to send message to Ticktimer");
|
|
||||||
if let xous::Result::Scalar2(upper, lower) = response {
|
if let xous::Result::Scalar2(upper, lower) = response {
|
||||||
upper as u64 | ((lower as u64) << 32)
|
upper as u64 | ((lower as u64) << 32)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -33,11 +31,9 @@ impl Ticktimer {
|
||||||
|
|
||||||
pub fn sleep_ms(&self, ms: usize) -> Result<(), Error> {
|
pub fn sleep_ms(&self, ms: usize) -> Result<(), Error> {
|
||||||
send_message(self.conn,
|
send_message(self.conn,
|
||||||
xous::Message::BlockingScalar(xous::ScalarMessage {
|
xous::Message::new_blocking_scalar(api::Opcode::SleepMs.to_usize().unwrap(),
|
||||||
id: api::Opcode::SleepMs.to_usize().unwrap(),
|
ms,
|
||||||
arg1: ms,
|
0, 0, 0)
|
||||||
arg2: 0, arg3: 0, arg4: 0
|
|
||||||
})
|
|
||||||
).map(|_| ())
|
).map(|_| ())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,8 @@ impl Trng {
|
||||||
}
|
}
|
||||||
pub fn get_u32(&self) -> Result<u32, xous::Error> {
|
pub fn get_u32(&self) -> Result<u32, xous::Error> {
|
||||||
let response = send_message(self.conn,
|
let response = send_message(self.conn,
|
||||||
xous::Message::BlockingScalar(xous::ScalarMessage {
|
xous::Message::new_blocking_scalar(api::Opcode::GetTrng.to_usize().unwrap(),
|
||||||
id: api::Opcode::GetTrng.to_usize().unwrap(),
|
1 /* count */, 0, 0, 0, )
|
||||||
arg1: 1 /* count */, arg2: 0, arg3: 0, arg4: 0
|
|
||||||
})
|
|
||||||
).expect("TRNG|LIB: can't get_u32");
|
).expect("TRNG|LIB: can't get_u32");
|
||||||
if let xous::Result::Scalar2(trng, _) = response {
|
if let xous::Result::Scalar2(trng, _) = response {
|
||||||
Ok(trng as u32)
|
Ok(trng as u32)
|
||||||
|
|
@ -29,10 +27,8 @@ impl Trng {
|
||||||
}
|
}
|
||||||
pub fn get_u64(&self) -> Result<u64, xous::Error> {
|
pub fn get_u64(&self) -> Result<u64, xous::Error> {
|
||||||
let response = send_message(self.conn,
|
let response = send_message(self.conn,
|
||||||
xous::Message::BlockingScalar(xous::ScalarMessage {
|
xous::Message::new_blocking_scalar(api::Opcode::GetTrng.to_usize().unwrap(),
|
||||||
id: api::Opcode::GetTrng.to_usize().unwrap(),
|
2 /* count */, 0, 0, 0, )
|
||||||
arg1: 2 /* count */, arg2: 0, arg3: 0, arg4: 0
|
|
||||||
})
|
|
||||||
).expect("TRNG|LIB: can't get_u32");
|
).expect("TRNG|LIB: can't get_u32");
|
||||||
if let xous::Result::Scalar2(lo, hi) = response {
|
if let xous::Result::Scalar2(lo, hi) = response {
|
||||||
Ok( lo as u64 | ((hi as u64) << 32) )
|
Ok( lo as u64 | ((hi as u64) << 32) )
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue