mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-25 00:02:28 +00:00
usb: add the Endpoint::is_enabled function
This commit is contained in:
parent
000b022ae2
commit
beab53b4ea
@ -473,6 +473,11 @@ impl<'d, T: Instance, Dir: EndpointDir> driver::Endpoint for Endpoint<'d, T, Dir
|
||||
async fn wait_enabled(&mut self) {
|
||||
self.wait_enabled_state(true).await
|
||||
}
|
||||
|
||||
fn is_enabled(&self) -> bool {
|
||||
let ep_addr = self.info.addr.index();
|
||||
Dir::is_enabled(T::regs(), ep_addr)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(private_bounds)]
|
||||
|
@ -538,6 +538,11 @@ impl<'d, T: Instance> driver::Endpoint for Endpoint<'d, T, In> {
|
||||
.await;
|
||||
trace!("wait_enabled IN OK");
|
||||
}
|
||||
|
||||
fn is_enabled(&self) -> bool {
|
||||
let index = self.info.addr.index();
|
||||
T::dpram().ep_in_control(index - 1).read().enable()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Instance> driver::Endpoint for Endpoint<'d, T, Out> {
|
||||
@ -560,6 +565,11 @@ impl<'d, T: Instance> driver::Endpoint for Endpoint<'d, T, Out> {
|
||||
.await;
|
||||
trace!("wait_enabled OUT OK");
|
||||
}
|
||||
|
||||
fn is_enabled(&self) -> bool {
|
||||
let index = self.info.addr.index();
|
||||
T::dpram().ep_in_control(index - 1).read().enable()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Instance> driver::EndpointOut for Endpoint<'d, T, Out> {
|
||||
|
@ -701,6 +701,11 @@ impl<'d, T: Instance> driver::Endpoint for Endpoint<'d, T, In> {
|
||||
.await;
|
||||
trace!("wait_enabled IN OK");
|
||||
}
|
||||
|
||||
fn is_enabled(&self) -> bool {
|
||||
let index = self.info.addr.index();
|
||||
T::regs().epr(index).read().stat_tx() != Stat::DISABLED
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Instance> driver::Endpoint for Endpoint<'d, T, Out> {
|
||||
@ -723,6 +728,11 @@ impl<'d, T: Instance> driver::Endpoint for Endpoint<'d, T, Out> {
|
||||
.await;
|
||||
trace!("wait_enabled OUT OK");
|
||||
}
|
||||
|
||||
fn is_enabled(&self) -> bool {
|
||||
let index = self.info.addr.index();
|
||||
T::regs().epr(index).read().stat_rx() != Stat::DISABLED
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Instance> driver::EndpointOut for Endpoint<'d, T, Out> {
|
||||
|
@ -225,6 +225,9 @@ pub trait Endpoint {
|
||||
|
||||
/// Wait for the endpoint to be enabled.
|
||||
async fn wait_enabled(&mut self);
|
||||
|
||||
/// Check if the endpoint is enabled.
|
||||
fn is_enabled(&self) -> bool;
|
||||
}
|
||||
|
||||
/// OUT Endpoint trait.
|
||||
|
@ -1008,6 +1008,11 @@ impl<'d> embassy_usb_driver::Endpoint for Endpoint<'d, In> {
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
fn is_enabled(&self) -> bool {
|
||||
let ep_index = self.info.addr.index();
|
||||
self.regs.diepctl(ep_index).read().usbaep()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d> embassy_usb_driver::Endpoint for Endpoint<'d, Out> {
|
||||
@ -1029,6 +1034,11 @@ impl<'d> embassy_usb_driver::Endpoint for Endpoint<'d, Out> {
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
fn is_enabled(&self) -> bool {
|
||||
let ep_index = self.info.addr.index();
|
||||
self.regs.diepctl(ep_index).read().usbaep()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d> embassy_usb_driver::EndpointOut for Endpoint<'d, Out> {
|
||||
|
Loading…
Reference in New Issue
Block a user