mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-26 00:32:33 +00:00
usb: parse request in embassy-usb instead of the driver.
This commit is contained in:
parent
30d4d0e9d7
commit
5fd55f9529
@ -9,7 +9,6 @@ use embassy::interrupt::InterruptExt;
|
|||||||
use embassy::util::Unborrow;
|
use embassy::util::Unborrow;
|
||||||
use embassy::waitqueue::AtomicWaker;
|
use embassy::waitqueue::AtomicWaker;
|
||||||
use embassy_hal_common::unborrow;
|
use embassy_hal_common::unborrow;
|
||||||
use embassy_usb::control::Request;
|
|
||||||
use embassy_usb::driver::{self, EndpointError, Event, Unsupported};
|
use embassy_usb::driver::{self, EndpointError, Event, Unsupported};
|
||||||
use embassy_usb::types::{EndpointAddress, EndpointInfo, EndpointType, UsbDirection};
|
use embassy_usb::types::{EndpointAddress, EndpointInfo, EndpointType, UsbDirection};
|
||||||
use futures::future::poll_fn;
|
use futures::future::poll_fn;
|
||||||
@ -682,14 +681,7 @@ impl<'d, T: Instance> driver::ControlPipe for ControlPipe<'d, T> {
|
|||||||
buf[6] = regs.wlengthl.read().wlengthl().bits();
|
buf[6] = regs.wlengthl.read().wlengthl().bits();
|
||||||
buf[7] = regs.wlengthh.read().wlengthh().bits();
|
buf[7] = regs.wlengthh.read().wlengthh().bits();
|
||||||
|
|
||||||
let req = Request::parse(&buf);
|
buf
|
||||||
|
|
||||||
if req.direction == UsbDirection::Out {
|
|
||||||
regs.tasks_ep0rcvout
|
|
||||||
.write(|w| w.tasks_ep0rcvout().set_bit());
|
|
||||||
}
|
|
||||||
|
|
||||||
req
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -697,6 +689,9 @@ impl<'d, T: Instance> driver::ControlPipe for ControlPipe<'d, T> {
|
|||||||
async move {
|
async move {
|
||||||
let regs = T::regs();
|
let regs = T::regs();
|
||||||
|
|
||||||
|
regs.tasks_ep0rcvout
|
||||||
|
.write(|w| w.tasks_ep0rcvout().set_bit());
|
||||||
|
|
||||||
// Wait until ready
|
// Wait until ready
|
||||||
regs.intenset.write(|w| {
|
regs.intenset.write(|w| {
|
||||||
w.usbreset().set();
|
w.usbreset().set();
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
use core::future::Future;
|
use core::future::Future;
|
||||||
|
|
||||||
use crate::control::Request;
|
|
||||||
|
|
||||||
use super::types::*;
|
use super::types::*;
|
||||||
|
|
||||||
/// Driver for a specific USB peripheral. Implement this to add support for a new hardware
|
/// Driver for a specific USB peripheral. Implement this to add support for a new hardware
|
||||||
@ -146,7 +144,7 @@ pub trait EndpointOut: Endpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub trait ControlPipe {
|
pub trait ControlPipe {
|
||||||
type SetupFuture<'a>: Future<Output = Request> + 'a
|
type SetupFuture<'a>: Future<Output = [u8; 8]> + 'a
|
||||||
where
|
where
|
||||||
Self: 'a;
|
Self: 'a;
|
||||||
type DataOutFuture<'a>: Future<Output = Result<usize, EndpointError>> + 'a
|
type DataOutFuture<'a>: Future<Output = Result<usize, EndpointError>> + 'a
|
||||||
|
@ -246,7 +246,9 @@ impl<'d, D: Driver<'d>> UsbDevice<'d, D> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_control(&mut self, req: Request) {
|
async fn handle_control(&mut self, req: [u8; 8]) {
|
||||||
|
let req = Request::parse(&req);
|
||||||
|
|
||||||
trace!("control request: {:02x}", req);
|
trace!("control request: {:02x}", req);
|
||||||
|
|
||||||
match req.direction {
|
match req.direction {
|
||||||
|
Loading…
Reference in New Issue
Block a user