mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
refactor callback methodology to match 0.8 conventions
This commit is contained in:
parent
0e936eaee3
commit
e3733fa64c
1 changed files with 7 additions and 11 deletions
|
|
@ -8,7 +8,7 @@ pub mod api;
|
||||||
|
|
||||||
use api::BattStats;
|
use api::BattStats;
|
||||||
use api::Opcode;
|
use api::Opcode;
|
||||||
use xous::{send_message, Error, CID, Message};
|
use xous::{send_message, Error, CID, Message, msg_scalar_unpack};
|
||||||
use xous_ipc::{String, Buffer};
|
use xous_ipc::{String, Buffer};
|
||||||
use num_traits::{ToPrimitive, FromPrimitive};
|
use num_traits::{ToPrimitive, FromPrimitive};
|
||||||
|
|
||||||
|
|
@ -23,18 +23,14 @@ fn battstats_server(sid0: usize, sid1: usize, sid2: usize, sid3: usize) {
|
||||||
loop {
|
loop {
|
||||||
let msg = xous::receive_message(sid).unwrap();
|
let msg = xous::receive_message(sid).unwrap();
|
||||||
match FromPrimitive::from_usize(msg.body.id()) {
|
match FromPrimitive::from_usize(msg.body.id()) {
|
||||||
Some(api::CallbackType::BattStats) => {
|
Some(api::CallbackType::BattStats) => msg_scalar_unpack!(msg, lo, hi, _, _, {
|
||||||
if let xous::Message::Scalar(xous::ScalarMessage {
|
let bs: BattStats = [lo, hi].into();
|
||||||
id: _, arg1: lo, arg2: hi, arg3: _, arg4: _
|
unsafe {
|
||||||
}) = msg.body {
|
if let Some(cb) = BATTSTATS_CB {
|
||||||
let bs: BattStats = [lo, hi].into();
|
cb(bs)
|
||||||
unsafe {
|
|
||||||
if let Some(cb) = BATTSTATS_CB {
|
|
||||||
cb(bs)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}),
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue