mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-25 08:12:30 +00:00
wpan: complete prelim. command impl.
This commit is contained in:
parent
899a68325c
commit
c675208b8a
@ -1,5 +1,6 @@
|
|||||||
use core::future::Future;
|
use core::future::Future;
|
||||||
use core::task;
|
use core::task;
|
||||||
|
use core::task::Poll;
|
||||||
|
|
||||||
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||||
use embassy_sync::mutex::MutexGuard;
|
use embassy_sync::mutex::MutexGuard;
|
||||||
@ -7,6 +8,7 @@ use embassy_sync::signal::Signal;
|
|||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
|
|
||||||
use super::commands::MacCommand;
|
use super::commands::MacCommand;
|
||||||
|
use super::event::MacEvent;
|
||||||
use super::typedefs::MacError;
|
use super::typedefs::MacError;
|
||||||
use crate::mac::runner::Runner;
|
use crate::mac::runner::Runner;
|
||||||
|
|
||||||
@ -62,10 +64,9 @@ impl<'a> EventToken<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Future for EventToken<'a> {
|
impl<'a> Future for EventToken<'a> {
|
||||||
// TODO: output something
|
type Output = MacEvent<'a>;
|
||||||
type Output = ();
|
|
||||||
|
|
||||||
fn poll(self: core::pin::Pin<&mut Self>, cx: &mut task::Context<'_>) -> task::Poll<Self::Output> {
|
fn poll(self: core::pin::Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
|
||||||
self.get_mut().runner.rx_event_channel.lock(|s| {
|
self.get_mut().runner.rx_event_channel.lock(|s| {
|
||||||
let signal = s.borrow_mut();
|
let signal = s.borrow_mut();
|
||||||
let signal = match &*signal {
|
let signal = match &*signal {
|
||||||
@ -73,10 +74,13 @@ impl<'a> Future for EventToken<'a> {
|
|||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = signal.wait().poll_unpin(cx);
|
let result = match signal.wait().poll_unpin(cx) {
|
||||||
});
|
Poll::Ready(mac_event) => Poll::Ready(mac_event),
|
||||||
|
Poll::Pending => Poll::Pending,
|
||||||
|
};
|
||||||
|
|
||||||
todo!()
|
result
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,12 +13,13 @@ use crate::mac::typedefs::{AddressMode, MacAddress, PanId, SecurityLevel};
|
|||||||
use crate::mac::MTU;
|
use crate::mac::MTU;
|
||||||
use crate::sub::mac::Mac;
|
use crate::sub::mac::Mac;
|
||||||
|
|
||||||
|
type ZeroCopyPubSub<M, T> = blocking_mutex::Mutex<M, RefCell<Option<Signal<NoopRawMutex, T>>>>;
|
||||||
|
|
||||||
pub struct Runner<'a> {
|
pub struct Runner<'a> {
|
||||||
pub(crate) mac_subsystem: Mac,
|
pub(crate) mac_subsystem: Mac,
|
||||||
|
|
||||||
// rx event backpressure is already provided through the MacEvent drop mechanism
|
// rx event backpressure is already provided through the MacEvent drop mechanism
|
||||||
pub(crate) rx_event_channel:
|
// therefore, we don't need to worry about overwriting events
|
||||||
blocking_mutex::Mutex<CriticalSectionRawMutex, RefCell<Option<Signal<NoopRawMutex, MacEvent<'a>>>>>,
|
pub(crate) rx_event_channel: ZeroCopyPubSub<CriticalSectionRawMutex, MacEvent<'a>>,
|
||||||
pub(crate) read_mutex: Mutex<CriticalSectionRawMutex, ()>,
|
pub(crate) read_mutex: Mutex<CriticalSectionRawMutex, ()>,
|
||||||
pub(crate) write_mutex: Mutex<CriticalSectionRawMutex, ()>,
|
pub(crate) write_mutex: Mutex<CriticalSectionRawMutex, ()>,
|
||||||
pub(crate) rx_channel: Channel<CriticalSectionRawMutex, MacEvent<'a>, 1>,
|
pub(crate) rx_channel: Channel<CriticalSectionRawMutex, MacEvent<'a>, 1>,
|
||||||
|
Loading…
Reference in New Issue
Block a user